Skip to main content

Full text of "C64DX aka C65 System Specifications Preliminary 1991 Mar"

See other formats


C64DX SYSTEM SPECIFICATION 



D Design Concepts 

D Hardware Specifications 

D Software Specifications 

Hexfuirea ROM Version 0.9A310228 or later. 



FWEUMMARY 



March, 1991 



Qs Commodore*^ 



fred@cbmvax 




C64DX SYSTEM SPEC UPDATE 1 



Printer queue: Ips20 

Started: Wed May 1 08:22:581991 



Digital Equipment Corporation 



PrintRpfwpr 90 



APPLICATION 



NEXT ASSY 



'>'>'>'i'>'> 



USED ON 



C64DX 



REVISIONS 



LTR 



DESCRIPTION 



PILOT PRODUCTION RELEASE 



DATE 



03/01/91 



APPROVED 



C64DX SYSTEM SPECIFICATION 



A.K.A. C65 



COPYRIGHT 1991 COMMODORE BUSINESS MACHINES, INC. ALL RIGHTS RESERVED. 

INFORMATION CONTAINED HEREIN IS THE UNPUBLISHED AND CONFIDENTIAL PROPERTY OF 
COMMODORE BUSINESS MACHINES, INC. USE. REPRODUCTION, OR DISCLOSURE OF THIS 
/ INFORMATION WITHOUT THE PRIOR WRITTEN PERMISSION OF COMMODORE IS PROHIBITED 



COMMODORE PART 



STATUS 



'>')'}')'>'} -')0 



PRELIM 



SIGN-OFF 



DRWN 



SYS 



TEST 



COMP 



FRED BOWEN 



FRED BOWEN 



DATE 



06/13/89 



06/13/89 



TITLE 



C64DX SYSTEM SPECIFICATION 
REVISION A (PILOT PRODUCTION) 



SIZE A 



SHEET 1 OF MANY 



System Specification for C65 Fred Bowen March 1, 1991 



cccc 


666 


555555 


c c 


6 


5 


c 


6 


5 


c 


6 


55555 


c 


66666 


5 5 


c 


6 6 


5 


c 


6 6 


5 


c c 


6 6 


5 5 


cccc 


sG6e 


5555 



Copyright 1991 Commodore Business Machines, Inc. 
All Rights Reserved. 



This docTomentation contains confidential, proprietary, and unpublished 
information of Commodore Business Machines, Inc. The reproduction, 
dissemination, disclosure or translation of this information to others 
without the prior written consent of Commodore Business Machines, Inc. 
IS strictly prohibited. 



N ^ice is hereby given that the works of authorship contained herein 
are owned by Commodore Business Machines, Inc. pursuant to U.S. 
Copyright Law, Title 17 U.S.C. 3101 et . seq. 



??''?v.?r^TL^ n 5""^^^^°".-,?^^^^^^^ ^^^ l^t^st information available 
at this time Updates will occur as the system evolves. Commodore 
Business Machines, Inc. makes no warranties, expressed or implied. 
With regard to the information contained herein including the quality 
performance, merchantability, or fitness of this information or th4 
system as described. . 



This system specification contains the contributions of several people 
including: Fred Bowen, Paul Lassa, Bill Gardei, and Victor Andrads 



Portions of the BASIC ROM code are Copyright 1977 Microsoft. 



System Specification for C65 



Fred Bowen 



.March 1, 1991 



PPPPP RRRRK EEEEE L 



III M 



M III N 



N AAAA RRRRR 



P R 
P R 

P R 



PPPPP 

P 

P 

P 

P 



R E 
R E 
R E 



RRRRR 
R R 
R R 
R R 
R R 



EEEE 
E 
E 
E 

EEEEE 



MM MM 
M M M M 
M M M 



LLLLLL III 



M 
M 
M 
M 
M 



NN N A 
N N N A 
N N N A 



M I N 

M I N 

M I N 

M I N 

M III N 



NN 
N 

N 
N 
N 



A R 
A R 
A R 



A 
A 
A 



A 
-A 
A 



R 



AAAAAA RRRRR 
A A R R 



R R 
R R 
R R 



Y Y 
.Y Y 

Y 

Y 
■ Y 

Y 

Y 

Y 



Revision 0*2 



(pilot release) 



January 31, 1991 



At this time, Pilot Production, the C65 system -consists of either 
revision 2A or 2B PCB, 4510R3, ^SeiRS (PAL only) , FOllB/C FDC, 
and 018 DMAgic chips. There will be changes to all these chips 
before Production Release. 



This work is by: 



Fred Bowen 
Paul Lassa 
Bill Gardei 
Victor Andrade 



System Software- C65 
Hardware engineer- C65, DMAgic 
LSI engineer- 4567, FDC 
LSI engineer- 4510 



Included are contributions by contractors hired by Commodore for 
the C65 project. These contributions include the DOS, Graphics, 
Audio, and Memory management areas. 

S-^eral 45 02 assembler systems are available: 

VAX, Amiga, and PC based BSO-compatible cross assemblers. 

PC based custom cross assembler by Memocom, compatible 
with Memocom 4502 emulator and Mem-ulator systems. 

C128-based BSO compatible cross assembler by Commodore. 



Custom software support is available for the following logic analyzers 
Hewlett Packard HP655x A and B logic analyzers. 



System Specification for C65 Fred Bowen, March 1, 1991 

Table of Contents 

1 . Introduction 

1 . 1 System Concept 

1.2 System Overview 

1.3 System Components 

1.4 System Concerns 

1.4.1 C64 Compatibility 

1.4.2 1581 DOS Compatibility 

1.4.3 Modes of Operation 

1 • 5 System Maps 



1.5.1 Composite System Memory Map 

1.5.2 C65 System Memory Map 

1.5.3 C65 System Memory Layout 

1.5.4 C65 I/O Memory Map 

2.0 System Hardware 

2 . 1 Keyboard 

2.1.1 Keyboard Layout 

2.2.2 Keyboard Matrix 

2.2 External Ports & Form -Factor 

2 . 3 Microcontroller 

2.3.1 Description 

2.3.2 Configuration * 

2.3.3 Functional Description 

2.3.3.1 Pin Description 

2.3.3.2 Timing Description 

2.3.3.3 Register Description 

2.3.4 Mapper 

2.3.5 Peripheral Control 

2.3.5.1 I/O Ports 

2.3.5.2 Handshaking 

2.3.5.3 Timers ' 

2.3.5.4 TOD Clocks 

2.3.5.5 Serial Ports 

2.3.5.6 Fast Serial Ports 

2.3.5.7 Interrupt Control 

2.3.5.8 Control Registers 

2.3.6 UART 

2.3.6.1 Control Registers , 

2.3.6.2 Status Register 

2.3.6.3 Character Configuration 

2.3.6.4 Register Map 



System Specification for C65 Fred Bowen March 1, 1991 

Table of Contents (continued) 

2.3.7 CPU 

2.3.7.1 Introduction 

2.3.7.2 CPU Operation 

2.3.7.3 Interrupt Handling 

2.3.7.4 Addressing Modes 

2.3.7.5 Instruction Set 

2.3.7.6 Opcode Table 

2.4 Video Controller 

2.4.1 Description 

2.4.2 Configuration 

2^4.3 Functional Description 

2.4.4 Programming 

2.4.5 Registers 

2.5 Disk Controller 

2.5.1 Description 

2.5.2 Configuration 

2.5.3 Registers 

2.5.4 Functional Description 

2.5.5 Expansion port protocol 

2.5.6 Timing diagrams 

2.6 Expansion Disk Controller (option) 

2.6.1 Description 

2.6.2 Expansion port protocol 

y 2.7 DMAgic Controller 

2.7.1 Description 
2 .-7. 2 Registers 

2.8 RAM Expansion Controller (option) 
2.8.1 Description 

2.9 Audio Controller » 



System Specification for C65 Fred Bowen . 

Table of Contents (continued) 



March 1, 1991 



3.0 System Software 

3.1 BASIC 10.0 



3.2 



3.1.1 
3.1,2 
3.1.3 
3.1.4 
3.1.5 
3.1.6 



Monitor 



Introduction 

List of Commands 

Command Descriptions 

Variables 

Operators 

Error Messages 

3.1.6.1 BASIC Error Messages 

3.1.6.2 DOS Error Messages 



3.3 


Editor 




3.3.1 




3.3.2 


3,4 


Kernel 




3.4.1 




3.4.2 




3.4.3 




3.4.4 




3.4.5 




3.4.6 




3.4.7 


3.5 


DOS 


3.6 


RS-232 



3.2.1 Introduction 

3.2.2 Commands and Conventions 

3.2.3 Command Descriptions 



Escape Sequences 
Control Characters 



Kernel Jump Table 

BASIC Jump Table 

Editor Jump Tabl^ 

Indirect Vectors 

Kernel Documentation 

BASIC Math Package Documentation 

I/O Devices 



4.0 



Development Support 



System Specification for C65 Fred Bowen March 1, 1991 

1.0 Introduction 

This specification describes the requirements for a low-cost 
8-bit microcomputer system with excellent graphic capabilities. 

1.1 System Concept 

The C65 microcomputer is a low-cost, versatile, competitive product 
designed for the international home computer and game market. 

The C65 is well suited for first time computer buyers, and provides 

n2„^^^Si^2S=^?^'^^'^® P^^^ ^°^ owners of the commercially successful 
^b^. Th-e C65 IS composed of concepts inherent in the C64 and C128 



The purpose of the C65 is to modernize and revitalize the 10 year old ■ 
C64 market while still taking advantage of the developed base of C64 
software. To accomplish this, the C65 will provide a C64 mode of 
operation, offering a reasonable degree of C64 software compatibility 
SL^^-^KM^^ "^^^u^^ °^ add-on hardware and peripheral compatibility. 
Compatibility can be sacrificed when it impedes enhanced functionality 
and expandability, much as the C64 sacrificed VIC-20 compatibility: 

rfic^^L^^^i''^?^^^'^ l^^^ ^^^ "^^""^ features and capabilities of the new 
alike ?h^r^L'^o''^i^i'^''^''^'=^v^^? ^^tention of developers and consumers 
alike, thereby revitalizing the low-end home computer market. The C65 
m^nhf^Sr^^ features that are normally found on today's more expensive 

?or tSe ir^^e The^rfi^^??r°^°'^^^^^^^^^°" °^ maximizing performance 
^^tv Lf?i^?; JS >,^H "^^1 P^°yi^e many new opportunities for third 
S?§in ?5«r ^*^ hardware developers, including telecornmunications, 
I^'^;°;.t?f-^""'^?^ control (including MIDI), and productivity as well 
as entertainment software. j ^ . 



System Specification for C65 Fred Bowen March 1, 1991 

1.2 System Overview 

o CPU ~ Commodore CSG45X0 running at 1.02 -or 3.5 Mhz 

o New instructions, including Rockwell and GTE extensions 

o Memory Mapper supporting up to 1 Megabyte address space 

o R6511-type UART {3-wire RS-232) device," programmable baud 
rate (50-56K baud, MIDI-capable) , parity, word size, sync 
and async. modes. XD/RD wire ORed/ANDed with user port. 

o Two CSG6526-type CIA devices, each, with 2 I/O ports, 

programmable TOD clocks, interval timers, interrupt contro 



Memory 



RAM— 128K bytes (DRAM) 

Externally expandable from additional 512K bytes to 4MB 
using dedicated RAM expansion port. 

ROM — 128K bytes 

064 Kernel and BASIC 2.2 

C65 Kernel, Editor, BASIC 10.0, ML Monitor {like 0128) 

DOS vlO- (1581 subset)- 

Multiple character sets: 40 and 80 column versions 

National keyboards/charsets for foreign language systems 

Externally expandable by conventional C64 ROM cartridges 

vxa cartridge/expans*6n port using C64 decodes. 

Externally expandable by additional 128K bytes or more 

via cartridge/expansion port using new system decodes. 

DMA -- Custom DMAgic controller chip built-in 
Absolute address access to entire 8MB system map, 
including I/O devices, both ROM & RAM expansion ports 
List-based DMA structures, can be chained together ' 
«?X (up, down, invert), Fill, Swap, Mix (boolean Minterms) 
Hold, Modulus (window) , Interrupt, and Resume modes 
Block operations from 1 byte to 64K bytes 
DRQ handshaking for I/O devices 
Built-in support for (optional) expansion RAM controller 



System Specification for C65 Fred Bowen . March 1, 1991 

1-2 System Overview (continued) 

o Video — Commodore CSG 4567 enhanced VIC chip 

o RGBA with sync on all colors or digital sync 

o Composite NTSC or PAL video, separate chroma/ltama 

o Composite NTSC or PAL digital monochrome 

o RF TV output via NTSC or PAL modulator 

o Digital foreground/background control (genlock) 

o All original C64 video modes: 

40x25 standard character mode 

Extended background color mode 

320x200 bitmap mode 

Multi-color mode 

16 colors 

8 sprites, 24x21 

o 4 and 80 character columns by 25 rows: 

Color, blink, bold, inverse video, underline attributes 

o True bitplane graphics: 

320 X 200 X 256 (8-bitplane) non-interlaced 

64 X 200 X 16* (4-bitplane) non-interlaced 

1280 X 200 X 4* (2-bitplane) non-interlaced 

320 X 400 X 256 (8-bitplane) interlaced 

640 X 400 X 16* (4-bitplane) interlaced 

1280 X 400 X 4* (2-bitplane) interlaced 

y *plus sprite and border colors 

o Color palettes: 

Standard 16-color C64 ROM palette 

Programmable 256-color RAM palette, with 16 intensity 

levels per primary color (yeilding 4096 colors) 

o Horizontal and vertical screen positioning verniers 

o Display Address Translator (DAT) allows programmer to 
access bitplanes easily and directly. 

o Access to optional expansion RAM 

o Operates at either clock speed without blanking 

O Audio — Commodore CSG8580 SID chips 

o Stereo SID chips: 

Total of 6 voices, 3 per channel 
Programmable ADSR envelope for each voice 
Filter, modulation, audio inputs, potentiometer 
Separate left/right volume, filter, modulation control 



System Specification for C65 Fred Bowen March 1, 1991 

^•2 System Overview (continued) 

o Disk, Printer support — 

o FDC custom MFM controller chip built in, with 512-byte 
buffer, sector or full track read/write/format, LED and 
motor control, copy protection. 

Built-in 3.5" double sided, INSB -MFM capacity drive 

Media & file system compatible with 1581 disk drive 

Supports one additional "dumb" drive externally. 

Standard CBM bus serial (all modes, about .4800 baud) 

Fast serial bus (C65 mode only, about 20K baud) 

Burst serial (C65 mode only, about 50K baud) 



o 
o 
o 
o 
o 
o 



o 



o 



o 



External ports — 

o 50-pin Cartridge/expansion port (ROM cartridges, etc.) 
o 24-pin User/parallel port (modem (1670), RS-232 serial) 
o Composite video/audio port (8-pin DIN) 
o Analog RGB video port (DB-9) 
o RF video output jack 

Serial bus port (disks (1541/1571/1581), printers, etc.) 

External floppy drive port (mini DINS) 

2 DB9 control ports (joystick, mouse, tablets, lightpen) 

Left and right stereo audio output jacks 

RAM expansion port, built-in support fo^ RAM controller 

Keyboard — 77 keys, including standard C64 keyboard plus: 
o Total of 8 function keys, F1-F16, shifted and nonshifted 
o ■ TAB, escape, ALT, CAPS lock, no scroll, help (F15/16) 
o Power, disk activity LEDs 
o Reset button 

Power supply — external, brick type 
o +5VDC at 2.2A and +12VDC at . 85A 



o 
o 
o 
o 
o 



System Specification for C65 



Fred Bowen 



March 1, 1991 



1.3 



S ystem Components 



Microcontroller: 
Memory : 

Video controller: 
Audio controllers 
Memory control : 
Disk controller: 



4510 (65CE02, 2x6526, 6511 UART, Mapper, Fast serial) 

4464 DRAM (128K bytes) 
271001 ROM (128K bytes) 

4567 (extended VIC, DAT, PLA) 

6581 (SID) 

41XX-F018 (DMA) 

41XX-F011 (FDC, supports 2 DSDD drives, MFM, RAM buffer] 



KEYS 
T DSER PORT 

T CONTROL PORTS 



T 



ADR 



DAT 



SERIAL BOS 



R L 

SPEAKERS 



FLOPPY PORT 



EXPANSION PORT 




pMOD^> RFOOT 
■J ^> COMP,CHROMA/LUMA 



•^ 



-> RGBA 

R 
£ 
C 



EXPANSION 
MEMORY 



128K 
RAM INTERNAL 



System Specification for C65 Fred Bowen March 1, 1991 

1.4 System Concerns 
1-4.1 C64 Compatibility Issues 

1.4.1.1 Software 

C64 software compatibility is an important goal. To this end, when the 
system xs xn "C64 mode" the processor will operate at average 1.02MHz 
speed and dummy "dead" cycles are emulated by the processor. The C€4 
ROM IS the same except for patches to serial bus routines in the kernel 
(to interface buxlt-in drive) , the removal of cassette code (there is no 
cassette port), and patches to the C64 initialization routines to boot 
C65 mode xf there is no reason <eg., cartridges) to stay in C64 mode. 

Compatibility with C64 software that uses previously unimplemented 6502 
opcodes (often associated with many copy-protection schemes) or that 
implements extremely timing dependent "fast loaders" is iherently 
impossible. Because the VIC-III timing is slightly different, programs 
tnat are extremely timing dependant may not work properly. Also 
because the VIC-III does not change display modes until the end of a 
character line, programs that change displays based strictly upon the 
fJ^^®TT^^??i^i°" ?^^ "^^^ display things properly. The aspect ratio of 

?cY? 7J^i.^.^^?^^^ ^^ slightly different than the VIC-II . The use of 
a 1541-11 disk drive (optional) will improve compatibility. C64 BASIC 
'^;LS'^?S -^"^^^ "^^^^ ^® -^^^^ (within hardware constraints). C128 
BASIC 10 compatibility will be moderate (graphic commands are different, 
some command parameters different, and there are many new commands). 

1*4.1.2 Hardware > 

C64 hardware compatibility is limited. Serial bus and control port 
devices (mouse, joysticks, etc.) are fully supported. Some user port 
devices are supported such as the newer (4-DIP switch) 1670 modems, but 
tnere s no 9VAC &o devices which require 9VAC won't function correctlv 
The expansion port has additional pins (50 total), and the pin spacing 
IS closer than the C64 (it's like the PLUS/4) . An adaptor ("WIDGET") - 
S'^iZu "®^«ssary to utilize C64 cartridges and expansion port devices 
Furthermore, timing differences between some C64 and C65 expansion 
port signals will affect many C64 expansion devices (such as the 1764). 

1.4.2 DOS CompatibilitY 

The built-in C65 DOS is a subset of Commodore 1581 DOS. There is no 
track cache, index sensor, etc. To load and run existing 1541-based 
applications, the consumer must add a 1541 drive to the system. Many 
commercial applications cannot be easily ported from 1541/5.25" media 
to i:>Bl/J.5 media, due to copy protection or "fast loaders". Most 
C64 applications that directly address DOS memory, specific disk tracks 
or sectors, or rely on DOS job queues and timing characteristics will 
not work with the built-in drive and new DOS. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



1.5 System Maps 

1-5.1 Composite System Memory Map 



C64 CARTRIDGES 




$EO0O 



$D000- 



$C000 



$A000 



$8000 



APPLICATION 
CARD HI 



APPLICATION 
CARD LOW 



$6000- 



C64 



$2000- 



$0000- 



KERNEL 

£ 
EDITOR 



COLOR NYBS 
I/O & CHARS 




C65 



KERNEL 

& 
EDITOR 



COLOR NYBS 
I/O i CHARS 



KERNEL 



BASIC 
GRAPHICS 



DOS 
(MAPPED) 



MONITOR 
(MAPPED) 



BASIC 



RAM-LO 



C65 EVEN 
BITPLAKES 



C65 BASIC 

TEXT 

S2000-$FEFF 



C64 VAH & 

STRINGS 

TEXT-$BFFF 

C64 BASIC 

TEXT 

$0800-VARS 



C65 SYSTEM 

TEXT SCREENS 



RAM-HI 



COLOR NYBS 



C65 ODD 
BITPLANES 



C65 VARS & 

STRINGS 
$2000-$F7FF 



C64 & 065 
DOS 



System Specification for C65 



Fred Bowen 



March 1, 1991 



1.4.3 Operating Modes 

The C65 powers up in the C64 mode. If there are no conditions present 
which indicate that C64 mode is desired, such as the C= key depressed 
or a C64 cartridge signature found, then C65 mode will be automaticallv 
brought into context. Unlike the C128, "C64 mode" is escapable Like 
S ^liy. ^^-^ °^ ^^® extended features of the C65 system are accessible 
froin C64 mode' via. custom software/ Whenever the system initiates C64 
mode, new VIC mode is always disabled except when the DOS is required 



System Specification for C65 



Fred Bowen 



March 1, 1991 



1.5.2 C65 System Memory Map 



MAPPER BANK 



IM SF.FFFF 

768K SCOOOO 

512K $8,0000 

2S6K $4,0000 

128K $2,0000 

$0,0000 



RAM 
EXPANSION 



RESERVED 



SYSTEM ROMS 



SYSTEM RAMS 



512K BLOCK APPEARING 
HERE IS DETERMINED BY 
THE RAM EXPANDER CTLR 
(IIP TO 8MB TOTAL MAP) 



FUTURE CARTRIDGES 



SEE SYSTEM MEMORY 
LAYOUT, BELOW 



System Specification for C65 



Fred Bowen 



March 1, 1991 



l*5-3 C65 System Hemoxn/ Layout 



$FFFF 
$F800 

$EO0O 

$D000 

$C000 

$A000 

$8000 



$4000 



$2000 



$0000 



BANK 
RAM-LO 



BITPLANES 
(EVEN) 



STRUCTURES 



BASIC 
TEXT 



TEXT SCREEN 



SYSTEM VARS 



BAKK 1 
RAM-fll 



COLOR NYBS 



BITPLANES 
(ODD) 



STRINGS 



BASIC 
VARIABLES 



DOS 

BUFFERS 
& VARS 



BANK 2 
ROM-LO 



C64 
KERNEL 



C64 CHRSET 



INTERFACE 



C64 
BASIC 



C65 
CHRSET 



RESERVED 



DOS 

(MAPS TO 
$8000) 



BANK 3 
ROM-HI 



C65 
KERNEL 



RESERVED 



GRAPHICS 



C65 BASIC 



MONITOR 

(MAPS TO 
$6000} 



System Specification for C65 



Fred Bow en 



March 1, 1991 



What does this Mean? Here is what the 64K memory map looks like in 
various configurations (i.e., as seen by the processor): 



C64 mode: 



$E0OO-$FFFF Kernel, Editor, BASIC overflow area 

$D0OO-$DFFF I/O and Color Nybbles, Character ROM 

SCOOO-SCFFF Application RAM 

SAOOO-SBFFF BASIC 2.2 

$0002-$9FFF RAMLO. VIC screen at S0400-$7FF. 

BASIC prog-ram & vars from $0800-$9FFF 



C65 mode: 



$E0OO-$FFFF Kernel, Editor ROM code 

$D0OO-$DFFF I/O and Color Bytes (CHRROM at $29000) 

$C0OO-$CFFF Kernel Interface, DOS ROM overflow area 

$8000-$BFFF BASIC 10.0 Graphics S Sprite ROM code 

$2000-$7FFF - BASIC 10.0 ROM code 

$0002-$lFFF RAMLO. Vic screen at $0800-$OFFF 

BASIC prgs mapped from $02000-$0FF00 
BASIC vars mapped from $12000-S1F7FF 



C65 DOS mode; 



$E0OO-$FFFF Kernel, Editor ROM code 

SDOOO-SDFFF I/O (CIA's mapped out). Color Bytes 

$C800-$CFFF Kernel Interface 

$8000-SC3FF DOS ROM code 
$2000-$7FFF [don't care] 

SOOOO-SIFFF DOS RAMHI 



Ob's Monitor: 



SE0O0-$FFFF Kernel, Editor ROM code 

$D0O0-$DFFF I/O and Color Bytes 

$C000-$CFFF Kernel Interface 
$8000-$BFFF [don't care] 

$6000-$7FFF Monitor ROM code 

$0002-$5FFF RAMLO. 



It's done this way for a reason. The CPU MAPPER restricts the programmer to 
one offset for each 32K-byte half of a 64K-byte segment. For one chuck bf 
ROM to MAP an another chuck with a different offset, it must do so into the 
other half of memory from which it is executing. The OS does this by never 
mapping the chunk of ROM at $COOO-$DFFF, which allows this chunk to contain 
the Interface/MAP code and I/O (having I/O in context is usually desireable, 
and you can't map I/O anyhow). The Interface/MAP ROM can be turned on and off 
via VIC register $30, bit 5 (ROM@$C000) , and therefore does not need to be 
mapped itself. Generally, OS functions (such as the Kernel, Editor, and DOS) 
live in the upper 32K half of memory, and applications (such as BASIC or the 
Monitor) live in the lower 32K half. For example, when Monitor mode is 
entered, the OS maps out BASIC and maps in the Monitor. Each has ready 
access to the OS, but no built-in access to each other. When a DOS call is 
made, the OS overlays itself with the DOS (except for the magical $C000 code) 
in the upper 32K half of memory, and overlays the application area with DOS 
RAM in the lower 32K half of memory. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



1.5.4 C65 System I/O Memory Map 



5DFO0 
5OEO0 


10-2 
lO-l 


$DD00 
$OC00 


CIA-2 
CIA-1 


$D8D0 


COLOR NYB 


$D700 


DMA 


5D600 


UART 


$D4<40 
5D400 


SID (L) 
SID (R) 


50300 
50200 
50100 


BLD PALETTE 
GRH PALEITE 
RED PAT.ETTE 


$DOAO 


KEC 


$DD80 


FDC 


50000 


VIC-4567 



EXTERNAL I/O SELECT 
EXTERNAL I/O SELECT 

SERIAL, DSER PORT 

KEYBOARD, JOYSTICK, MOUSE CONTROL 

COLOR MATRIX C*FROM $1F800-1FFFF) 

*DMA CONTROLLER 

*RS-232, FAST SERIAL, NEW KEY LINES 

AUDIO CONTROLLER (LEFT) 
ADDIO CONTROLLER (RIGHT) 

*COLOR PALETTES (NYBBLES) 

*RAN EXPANSION CTRL (OPTIONAL) 
*DISK CONTROLLER 
VIDEO CONTROLLER 



50000 



4510 



MEMORY CONTROL FOR C64 MODE 
(this register is actually in 
the VIC-4567 in the C65) 



*NOTE: VIC must be in "new" mode to address these deyices 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2. C65 System Hardware 
2.1.1 Keyboard Layout 



RUN 
STOP 



ESC 


ALT 


CAPS 
LOCK 


NO 
SCRL 



Fl 
F2 


F3 
F4 


F5 
F6 


F7 
F8 



F9 
FIO 


Fll 
F12 


F13 
F14 


HELP 



<- 


1 

i 


II 
2 


# 

3 


$ 
A 


% 

5 


6 


7 


( 
8 


) 
9 





+ 


. 


£ 


CLR 
HOME 


INST 
DEL 


TAB 


Q 


W 


E 


R 


T 


Y 


U 


I 





P . 


@ 


* 


IT 

A 


RSTR 


CTRL 


SHFT 
LOCK 


A 


S 


D 


F 


G 


H 


J 


K 


L 


[ 


] 


s: 


RETtJRN 


C= 


SHIFT 


z 


X 


C 


V 


B 


N 


M 


< 

* 


> 


•3 


SHIFT 


CRSR 
DP 














SPACE 






CRSR 
LEFT 


CRSR 
DOWN 


CRSR 

RITE 



Notes 



1/ 



The cursor keys are special- the shifted cursor keys appear as separate 
keys, but in actuality pressing them generates a SHIFT plus the normal 
cursor code, making them totally compatable with, and therefore functional 
in, C64 mode. 

2/ There are a total of 77 keys, two of which are locking keys. 

3/ The NATIONAL keyboards are similar, and their layout and, operation is 
identical to their C128 implementation. 



System Specification for C65 

2.1.2 Keyboard Matrix 



Fred Bowen 



March 1, 1991 



CO 
PIK20 



CI 
PIN19 



C2 
PIN18 



C3 
PIN17 



C4 
PIN16 



C5 

PIN15 



C6 
PIN14 



C7 
PIN13 



08 

PIN-4 



GND 
PIN-1 



RO 
PIN12 



Rl 
PINll 



R2 
PINIO 



R3 
PIN-9 



R4 
PIN-8 



R5 
PIN-7 



R6 

PIN- 6 



R7 
PIN-5 













% 
5 


7 


} 
9 


""" 




— 




r— 




NO 

SCRL 






DEL 


f 

3 


+ 


£ 


1 

i 




RET 


W 


R 


y 


I P 


^ , 


TAB 




< 


* 


<~ 




H0R2 
CRSR 


A 


D 


G 


J 


L 


] 


CTRL 


ALT 






F8 
F7 


$ 
4 


& 

6 


8" 





- 


CLR 
HOM 


ti 
2 


HELP 




F2 
Fl 


2 


C 


B 


M 


> 


RIGHT 
SHIFT 


SPACE 
BAR 


no 

F9 




F4 
F3 


S 


F 


H 


K 


[ 


= 


C= 


F12 

Fll 






F6 
F5 


E 


T 


U 





e 




Q 


F14 

F13 






VERT 
CRSR 


LEFT 
SHIFT 


X 


V 


N 
? 


< 


/ 


RUN 
STOP 


ESC 


























/ 
1 t 


(LOCKING) 












SHIFT 
LOCK 


















- 
















4066 
DECODER 






CRSR 
OP 








Kl PIN-21 














i 




CRSR 










L££ 


•T 






K2 P 


IM-22 















NMI 
PIN-3 



RESTR 



R8 
PIN-2 



CAPS 
LOCK 



/ (LOCKING) 



System Specification for C65 Fred Bowen March 1, 1991 

Keyboard Notes: 

1/ The 64 keys under CO through C7 occupy the same matrix' position as in-the- 
C/64, as does the RESTORE key. Including SHIFT-LOCK, thSre are slsuch kl^s. 

'^^ th^ rAPq"?orv^v^^°^jK ^°"sists of the 8 keys under' the 08 output. Counting 
the CAPS-LOCK key, there are 9 new keys. The C/64 does not sSan these k^yl. 

^^ key co^iSt?on^^^^ ^""^ '''^^''^ "^ ^^^^ simulate a CURSOR plus RIGHT SHIFT 

4/ The keyboard mechanism will be mechanically similar. to that of the C128. 



System Specification for C65 



2 . 2 Form Factor 



Fred Bowen 



March 1, 199l' 



j^' 



EXPANSION 
PORT 



SERIAL 
BOS 



POWER CONNECTOR 

POWER SWITCH 
CONTROL PORT *2 

CONTROL PORT #1 
RESET 



DSER PORT 
(PARALLEL) 



STEREO 
L R 
1— LJ— I 1 



RGBA RF C(MPOSITE FAST DISK 
VIDEO VIDEO. VIDEO PORT 






RAM EXPANSION (BOTTOM) 



3.5" 

DISK DRIVE 

EJECT 



TZJ 



Notes: '> 

1. Dimensions: about 18" wide, 8" deep, 2« high 

2. Disk unit faces forward. 



System Specification for C65 



Fred Bo wen 



2.3 



The CSG 4510 Mic-r» controller rhip 



March 1, 1991;- 



2.3.1 Description 



processSr^^652E02f''^^j; ^^^^^"^ "^^I^^^ ^^^^ contains an enhanced 6502 micro- 

I/O (UART Channel with programmable baud rate aeneratoi "bull? ?i^ serial 
map function to access nn i-n i «a«*K**r £ yenera^or, i3uij.t-in memory 

for synchronous SSr^ff! I/O^^n/ir^faLlL^Sr^ro^xfiiSi^.f ^^^ !|lL^!^" 
2.3.2 Configuration 



A3 

A4 

A5 

A6 

A7 

A8 

A9 

AlO 

All 

A12 

A13 

A14 

A15 

Aig 

A17 

A18 

A19 

PSYNC 

AEC 

DMA* 

NOIO 



A A A F S C 



2 1 



L R N 
A Q T 
Gil 

2 K 

* * 



s c s 

P N P 

1 T 2 

2 



VVCCRERINRTT 

CSOAEXSRMXXE 

CSLPSTTQIi)DS 

8 S E R R * * T 

L T * * 

K * 



^ ^ 8888877777 

10 9 8 7 6 5 4 3 2 14 3 2 10 9 8 7 6 5 




•1 ] n 7 ? ^ ^ ^ ^ ^ ^ ^ 4 4 4 5 5 5 5 
3 4 5 6 7 8 9 12 3 4 5 6 7 8 90123 

NDDDDDDDDvPRPPppppppp 

M76S4321OCOW012345672 
P 



74 


C7MH2 


73 


SRQDAT 


72 


SRQCLK 


71 


SRQATN 


70 


PA2 


69 


C0L7 


68 


C0L6 


67 


COLS 


66 


C0L4 


65 


C0L3 


64 


C0L2 


63 


COLl 


S2 


COLO 


61 


R0W7 


60 


R0W6 


59 


R0W5 - 


58 


R0W4 , 


57 


ROWS 


56 


R0W2 


55 


ROWl 


54 


ROWO 



System Specification for C65 



Fred Bowen 



March 1, 1991 



S.1? B^S^? - O^'pX'u^.X 



System Specification for CSS 

2.3.3 Functional Description 
2.3.3.1 Pin Description 



Fred Bowen 



March 1, 1991 



PIN 
NAME 

yss 
vcc 

SPB, 
SPA 



PIN 

NUMBER 



SIGNAL 
DIRECT ION 

IN 



DESCRIPTION 



2,42 

3 
5 



CNTB, 

CNTA, 



FLAGA/ 
FLAGS/ 



This is the power ground signal (0 volts) ; 

IN This is the power supply signal (+5 volts) . 

I/O The SPA and SPB. signals are open-drain and bi~ 
I/O directional, each with a 3K ohm (min.) passive 
pull-up, The SPA and SPB signals are the data 
lines used by the two 8-bit synchronous serial 
port registers. In input mode, SPA and SPB are 
clocked into the device on the. rising edge of 
the CNTA and CNTB clocks, respectively. In the 
output mode, SPA and SPB change on the failing 
edge of the CNTA and CNTB clocks, respectively. 

4 I/O The CNTA and CNTB signals are open-drain and bi- 

6 I/O directional, each with a 3K ohm (min.) passive ■ 

pull-up. These pins are internally synchro- 
nized to the PHO clock and then used to clock 
the synchronous serial' registers, in input mode. 
In output mode, each pin will reflect the clock 
signal derived from the corresponding timer. 

7 I/O The FLAGA/ and FLAGS/ inputs are negative edge 

8 IN sensitive input signals. A passive pull-up (3K 

ohm min) is tied on each of these pins. They 
are internally synchronized to the PHO clock and 
are used as general purpose interrupt inputs. 
Any negative transition on either of these 
signals will cause the device to start an 
interrupt sequence, provided that the proper bit 
is set in each of the interrupt mask registers. 
The device will drop the IRQ/ line to indicate 
that an interrupt sequence is underway. 

*** When the FAST SERIAL MODE is enabled the CNTA, SPA and *** 
*** FLAGA/ lines will not function as described above. See *** 
*** section 2.3.6 for FAST SERIAL MODE description. *** 



A0-A19 9 thru 28 



I/O Address Bus - This is a 20 bit bi-directional 

bus with tri-state outputs. The output of each 
address line is TTL compatible, capable of 
driving .two standard TTL loads and 55 pf. When 
the AEC or DMA/ line goes low, the bus goes tri- 
state. If AEC only is low, A17, A18 and A19 
will each reflect the state of the A16 line. 
During an I/O access (10/ is low), A0-A3, A8 and 
A9 are used to select an internal I/O register. 
If AEC is high, the bus will be driven by the 
CPU and A16-A19 will point to a mapped memory 
location (if MAP/ is low). If memory is hot 
mapped (MAP/ is high), A16-A19 will be low. 



Systein Specification for C65 t-^^ n 

^^^'^ S°"«" March 1, 1991 

PSYNC 29 nriT ^u- 

^^^s output line is provided tb^ iden-f-i f,, ^v 
cycles in which the microprocessbr is h^,- °^^ 
OP CODE fetch. The PSYNC linlaoes hi^^ h^ ^" ' 
PHI of an OP CODE fetch and Slays high^Lr'^tK^ 
remainder of that cycle. If AEC nn ^mi.;^ ^?® - 

ts^mM'^i f^'^t^^t^'^ '' ^^^^' wSicr^uli.'"" 

PSYNC went high, the processor will stoS in ^i-^ 
current state and will remain in the s?ate",n^?v 

the'^S^Nfsiana?'^^ ^^^ ""'t'' ^" thif ^^^ne?""' 
thl Ie^ or^Sw ?-" ^^ ^^^^ ^^ control either 
exlcS?Ln! ^^ ^""^ ^^ ^^"^^ ^^^5^« instruction 

^^ T?i;^ ^""S?^ "'i?"^^ ^^ the Address Enable Control 
line. When high, the address bus, R/W are 

are'fn a*^?Sh'^"' 5'^ "^^^^^= ^^^ ^^" ^^^ MAP/ " 
lit tL\?i^^'''!?P®'^"*=^ st^te except for AItT - 

thf X?6 line^^^^ °' "^''^^ "'^' ^^ connected to 
^^ ^^ ^^^® signal is connected to a 3K passive null 

Sxtern^l nin ^^ ^^^'Stated. This will allow 
lystirbus'ti^SI?"^^ '^ ^^^^^ control Of the , 

(HEADY) internal Signal ^^^s signal is genexated internally via the 

cvcl^r^'^rf^^ ^'^ ^''^ cycles includSg wrfte 
Surin^^H^ low_ state on either DMA/ or AEC 

■ f r ? ^^® rising transition of phase one (Pm\ 
Will deassert the READY line and ha!? thl iicro- 
processor with the output address lines holding 
the current address. This feature aUows niicrc 
processor interfacing with low speed niemorvar C 

This input signal is used to select the intern;,! 
registers of the device, provided memory is SS? 
being mapped by the CPU. ^ "^ 

This signal is passively pulled-up (3 Kohml 
whenever DMA/ or AEC is pSlled low. ^ 
This output signal is used to indicate whether 

tt the 7tn°^^ ^L^^^"? "^PP^^ ^y th^ device 
tL mL^ V-^^ addressing a mapped memory region 
the MAP/ lane will go low and will inhibit thS 
If fche^rpn''^"' selecting an internal register. 

•1^^ ^^ ^^ "°^ mapping memory the MAP/ line 
wUl be- high and A16-A19^ill be kept low. 



10/ 32 IK 
MAP/ 33 QUT 



System Specification for C65 
DB7-DB0 34 thru 41 I/O 



R/W 



43 



I/O 



PHO 



44 



IN 



PC/ 



53 



.PRD0-PRD7 45 thru 52 
PRB0-PRB7 54 thru 61 
PRA0-PRA7 62 thru 69 



PRC2 



70 



OUT 



I/O 
I/O 
I/O 



I/O 



PRC3 



71 



OUT 



PRC4 6 



72 



I/O 



Fred Bowen March 1, 1991'- 

D0-D7 form an 8 bit bi-directional data bus f or-- ■ 
data exchanges to and from the internal CPU (the 
65CE02) and the device internal registers. It 
is also used to comrnunicate with external peri- 
pheral devices. The output buffers are capable 
of driving two standard TTL loads and 55pf. 

This signal is generated by the CPU to control 
the direction of data transfers on the data bus. 
This line is high except when the CPU is writing 
to memory, an internal I/O register or an 
external device. When the AZC or DMA/ signal is 
low, the R/W becomes tri-state. 

This clock is a TTL compatible input used for " :. 
internal device operation and as a timing refer- 
ence for communicating with the system data bus. 
Two internal clocks are generated by the device; 
phase two (PH2) is in phase with PHO, and phase 
one (PHI) is 180 degrees out of phase with PHO, - 

This output line is a strobe signal and is Cen- 
tronics interface compatible. The signal goes 
low following a read or write access of PORT D. 

These are three 8-bit ports with each of their ■ 
lines having a passive pull-up (min. 3K ohm) 
as well as active pull-up and pull-down tran- 
sistors. Each individual port line may be 
programmed to be either input or .output. 

This, line corresponds to PORT C, bit 2. It has' 
passive pull-up (min. 3k ohm) as well as active 
pull-up and pull-down transistors. The line can 
be configured as input or output. PRC2 becomes - 
the external shift register clock when the UART 
is configured to operate in the synchronous 
mode, otherwise PRC2 operates as normal. 

This signal is an open drain output with a . 
passive pull-up {IK ohm min) . It corresponds to 
bit 3 of PORT C. When this port bit is set as 
an input, the PRC3 line is driven low; reading 
the port bit will give a high. If configured as 
an output, reading this port bit will not give 
the. status of the PRC3 line but the value pre- 
viously written on the PORT C^data reg. bit 3. 

This is an open drain bi-directional signal with 
a passive pull-up (IK ohm min) . Bit 6 of PORT C 
is always configured as an input; the bit will 
give the status of the PRC4 5 line anytime the 
the port is read, regardless of what is written 
in the data direction register. 

If bit 4 of PORT C is set as an input, the PRC4 6 
line will be pulled low; reading the port bit 
will give a high. If bit 4 is configured as 
an output, PRC46 will be pulled low if bit 4 in 
the port data register is high, otherwise the 
PRC4 6 line will float to a high. 



System Specification for C65 
PRC57 73 - I/O 



PRE0,PRE1 83, 84 



I/O 



BAUDCLK 



74 



IN 



TEST 



75 



IN 



TXD 



76 



OUT 



RXD 



77 



IN 



Fred Bowen 



March 1, 1991 



This xs an open drain bi-directional signal with 
a passive pull-up (IK ohm min) , Bit 7 of PORT r 
IS always configured as an input; the bit wnt 
give the status of the PRC57 lin; anytime the 
the port IS read, regardless of what is writlen - 
m the data direction register ^ wrmten 
If i^it 5 of PORT C is set as aA input, the J'RC57 
line will be pulled low; reading the port bit 
will give a high. If bit 5 is configured as 
an output, PRC57 will be pulled low if Sit 5 in 
oSoc?°f^ "^^^^ register is high, otherwise the 
PRC57 line will float to a high. ^« ^^e 

This a 2-bit port with each line having a 
passive pull-up (min. 3K ohm) as well as active 
pull-up and pull-down transistors. Each indi- 
vidual port line may be programmed to be eith* " 
input or output. =-»-<-iu ^.^ 

li^tt l^^'i^ ^® ^ '^^^ c^ock used to drive the 
UART Baud Rate Generator> and is assumed to ■ 
be synchronous with the PHO clock. This clock 
IS also divided down to iMHz to drive the 
interval timers, and down to lOHzto drive the 

J?° li'^^''^' ^^^^ ^^°=^ ^s ^Iso used to time out 
the POR and RESTORE (RSTR*) circuits. 

When this input goes to a high state, the device 
will operate m a test mode. The test mode will 

the'^OD^'anf S?'' ^ri^""^ "° ^" initialised ind 
tne TOD and interval timers to be driven 

divfders-^^ ^^^ BAUDCLK clock, bypassing all the 

This is the UART transmit data output line 
The LSB of the Transmit Data Register is the 
first data bit transmitted. The data trans- 
mission rate (baud rate) is determined by the 
value written to the Baud Rate Timer latches. ' -= 

This is the UART receive data input line and 
tL''??!^!?^!'^.^°w^ passive pull-up (IK ohm min) . 
j^t ii^l "^r^ ^^^ received is loaded into the 
LSB of the Receive Data Register. The receiver 

h5 ^hf^^^i"^^^ ^^ ^^^ ^^"'^ ^? ^^^^^ determined 
by the value written to the Baud Rate Timer 
latches. j-xxhcx 



^K 



System Specification for C65 Fred Bowen « ^ 

xrea tjowen March 1, 1991 



NMI/ 78 I/O 



IRQ/ 79 I/O 



The NMI/ pin is an open drain bi-directional 
illTL rtl^^^^""^ pull-up (3K ohms minimu^l is 
rn Ho ?,■ 5^f ^^^L allowing multiple NMI/ sources 
to be tied together. A negative transition oS 
this pm requests a non-maskable interrupt 
sequence to be generated by the microprocessor 
pSymp"^!?^^^^ sequence will begin with ^Sllirst 
PSYNC after a multiple-cycle opcode. NMI/ inout^ 
cannot be masked by the processor status ^ 

Pcfanf PCL 'a^d .?" ^"° ^""^^^ ^^^^^^^ ^Vtes 
^LH and PCL. and the processor status register 

P, are pushed onto the stack. Then the proarL 

pShef ;3S!/^^i^ --^^^^^ , 

ThS^NS?/-i -^^^^ ^^°"^^ ^^ t^^^" to avoid this. - 
ani ^hi^H^''^^ IS normally off (high impedance 
f^ i.h^^'^®''f:^® ""^^^ activate it low as described 
in the functional description. AEC and DM^/ must 
be high for any interrupt to be recognized. 

drain^h?''^^'' Request line (IRQ/) is an open 
n«^?v iv ^^^^■°"^^ signal. A passive pSll- 
up (JK Ohms minimum) is tied on this pin, 
f^iSri"^ inultiplelRQ/ sources to be connected 
together. This pin is sampled during PH2 and 
"^^i? s negative transition is detected an inter- 
rupt will be activated, only if the mask flag 
U) m the status register is low. The inter- 
rupt sequence will begin with the first PSYNC 
arter a multiple-cycle opcode. The two program 
counter bytes PCH and PCL, and the processor 
status register P, are stored- onto the stadk; 

further^?RO?^ ""^"^ ^^^^ ^' ^^^ ^^^h so that no 
±urther IRQ/'s may occur. At the end of this ' 

cycle, the program counter low byte (PCD will 

^^^^°^^ed from address FFFE, and^he high byte 

(PCH) from FFFF, thus transferring prog?am 

iSe IRO/^?in^"-r^^°" ^?^^^f^ ^^ ^^^^ IdSresses. 
Inri m A^^ IS normally off (high impedance) 
and^the device will activate it low as described 
h2 h?SK^^"=^^°"^^ description. AEC ani EmTmutt 
be high for any interrupt to be recognized. 



System Specification for CSS 
RESTR/ 80 IN 



£XTRST/ 



81 



OUT 



RESET/ 



82 



I/O 



Fred Bowen 



March 1, 1991 



This input is tied to a 3K ohm (min.) passi,,« 
pull-up. A bounce eliminator circuit if uleS 
on this pin to remove any bounce during its 
falling transition, if the pin is tied to a 
contact closure. If the device sees a n^L • 
transition on this pin, it wiU !^ldL?elv ""^ 

?^r^TL^^^ ''"^^ ^^"^ ^° =^^^ ^ Non^Maskabie In- 
terrupt sequence. The device will ignore an v 

subsequent transitions on the RESTR/ iin| until 

This output is an open drain output with a min 
IK Ohm pull-up. This pin will only go to a IS; 
^l^ll^^^'^^^^Po^^^'-^P. and will stay^low until 
volllge?''^ "^^^^ "^"^ ^^^ ^^^=^^^ ^^^ operating . 

The Reset line (RESET/) is an open drain bi- 
directional signal. A passive pull-up (IK ohm 
minimum) is tied on this pin, allowing iny l^ 
ternal source to initialize the devici a iL 
6Sr?^f ^^^^H^ instantly initialize IS^ internal 
65CE02 and all internal registers. All port 

?ero Trill SI JS^"^^ ""^ ^^^^ register^to 
zero (a read of the ports will return all hiahs 

rIgiSlerf a?r^ir.^"''""P"*i ^^^ timer cont?S? 
"ones In Itl ^"'^^ ^"^ ^^^ ^^^^^ latches 

to ones. All other registers are reset to zero 

hiS^Q^°"^''"w^ ^SET/ is held low and wiU go 
high .9 seconds after VDD reaches the operating 
voltage If pulled low during operation the 

rZTlnl i^^=^^\"5 °^^ode wi!l Ee terminated. 
The B and Z registers will be cleared The stick 

biti E^SSS ? ■^? S^^^ ^* ^^^ processor status 
cits E and I will be set. When the hiah i-rAr.- 

^"'HZ'' ^1 detected, the reset sequence beginS 
on the CPU cycle. The first foS cycle! of the 
reset sequence do nothing. Then thl^progr^ - 



System Specification for CSS Fred Bowen 

2.3.3.2 4516r3 Timing Description 



March 1, 1991 



TABS 1 + f— TAEH 



■TPWH 



■AEC, DMA 



PHO 



-TPWL 



TAIS 1 



■TAIH 



VALID 



TAOS 



-TAOH 



VALID 



TDIS| 1 ItDIH 



Htdos — j 



VALID 



I |TD0H 



VALID 



NOIO,R/W 

-A0-A19,NOMAP 
(INPUT) 



-PSYNC,R/W 
A0-A19,NOMAP 
' (OUTPUT) 



-D0-D7 



AEC, DMA 



TA2 



I T2A 



ON 



Tpwh 

Tpwl 

Taes 

Taeh 

Tais 

Taih 

Taos 

Taoh 

Tdis 

Tdih 

Tdos 

Tdoh 

Taz 

Tza 

Teh 

Tel 

Tcci 



ON D0-D7,R/W,A0-A15(AEC, DMA) 
A16-A19 (DMA) 



-TCH 



C7MH2 



-TCL 



Param Description 



1 " I — -TCCL 



PHO 



PHO Qlock high time 
PHO clock low time 
AEC, DMA setup to PHO falling 
AEC, DMA hold from PHO falling 
address input setup to PHO rising 
address input hold from PHO falling 
address output setup from PHO falling 
address output hold from PHO falling 
data input setup to PHO falling 
data input hold from PHO falling 
data output setup from PHO rising 
'data output hold from PHO failing 
address off from AEC or DMA falling 
address on from AEC and DMA rising 
C7MHZ clock high time 
C7MH2 clock low time 
C7MH2 delay from PHO 



MIN 



TYP 



MAX 



65 , 


135 


65 


i 135 


30 


— 


10 


— 


20 


- 


10 


- 


15 


_ 


40 


- 


10 


- 


30 


_ 





15 


15 


— 


65 


_ 


65 


_ 





_ 



50 



50 

20 
30 



50 



System Specification for C65 

2.3.3.3 Recrister Descrip tion 



Fred Bowen 



March 1, 1991 









must contain the valid address of ^hJ^^^^s «^-«i^ ^^'k a9 address lines ?1» 



A9 A8 










































1 
■1 
1 
1 
1 
1 
1 
1 
1 
1 













1 

1 

1 

1 

1 

1 

1 

1 

1 

1 

1 

1 

1 

1 

1 

1 














A3 A2 Al AO ■ HEX ADD REG SYMBOL 



























. 


























- 












REGISTER NAME 





1 
1 
1 
1 
1 
I 
1 
1 











1 

1 
1 

■1 
1 
1 
1. 
1 










1 
1 




0' 






1 

1 
1 

1 






1 
1 
1 
1 











1 
1 
1 
1 






1 

1 
1 
1 






1 

1 
1 

1 






1 
1 




1 
1 




1 
1 





1' 
1 




1 
1 




1 
1 




1 
1 




1 
1- 




1- 
1 




1 
1 








1- 



1 



1 



1 



~" 1 



1 



1 



1 



1 



1 



1 



1 



1 



1 

• 
1 



1 



1 



1 



1 

■ 
1 



1 



0X0 
0X1 
0X2 
0X3 
0X4 
- 0X5 
0X6 
0X7 
0X8 
0X9 
OXA 
QXB 

oxc 

. OXD 
CXE 
OXF 

1X0 

1X1 

1X2 

1X3 

1X4 

1X5 

1X6- 

1X7 

1X8 

1X9 

IXA 

IXB 

IXC 

IXD 

IXE 

IXF 

2X0 
2X1 
2X2 
2X3 
2X4 
2X5 
2X6 
2X7 
2X8 
2X9 



PRA 

PRE' 

DDRA 

DDRB 

TA LO 

TA HI 

TB LO 

TB HI 

TODATS 

TODAS 

TODAM 

TODAH 

SDRA 

ICRA 

CRA 

CRB 

PRC ■ 

PRD 

DDRC 

l5rd 

TC LO 

TC HI 

TD LO 

TDHI 

TODBTS 

TODBS 

TODBM 

TODBH 

SDRB 

I CRB 

CRC 

CRD 

DREG 

URSR 

URCR 

BRLO 

BRHI 

URIEN 

URIFG 

PRE 

DDRE 

F SERIAL 



Peripheral Data Reg A - ; 
Peripheral Data Reg "B ■" 
Data Direction Reg A ^ 
Data Direction Reg B ■ 
Timer A Low Register 
Timer A ■ High Register 
Timer B Low Register" '- 
Timer B High Register 
TODA lOths Sec Register --■ 
TODA Seconds Register 
TODA Minutes Register 
TODA Hours-AM/PM Reg 
SERIALA Data Register 
INTERRUPTA Control Reg. 
Control Register A 
Control Register B 

Peripheral Data Reg C 
Peripheral Data Reg D 
Data Direction Reg C 
Data Direction Reg D 
Timer C Low Register 
Timer C High Register 
Timer D Low Register 
Timer D High Register 
TODB lOths of Sec Reg. ' 
TODB Seconds Register 
TODB Minutes Register 
.TODB Hours-AM/PM Reg. 
SERIALS Data Register 
INTERRUPTS Control Reg. 
Control Register C 
Control Register D 

Receive/Transmit Data Reg 
UART Status Register 
UART Control Register 
Baud Rate Timer LO Reg. 
Baud Rate Timer HI Reg. 
UART IRQ/NMI Enable Reg. 
UART IRQ/NMI Flag Reg. 
Peripheral Data Reg. E 
Data Direction E 
Fast Serial Bus Control 



'■■i^f 



REGISTER ADDRESS ALLOCATION 
TABLE 1 



System Specification for C65 : -"Fred 

1 The functional description of the memory 
! The Fast Serial register is described in 

i '■-■," 

2.3.3.3.1 BEGISTilR BIT ALIOCATION 


Bowen ' :'; March 1> 

mapper follows in section 2 
section 2.3.5.6. 


1991 ^'t 

.3:4. 

DO 




i 


R/W REG 


NAME D7 D6 D5 


D4 D3 - D2 Dl 




t 

i 

i 
1 

! > 

i 

! 


R/W 


0X0 


PRA 


PA7 . 


PAS _ 


PAS 


PA4 


PA3 


PA2 


PAl 


PAO 


\ '. .:.:■■■ 


R/W 


0X1 


PRE- 


PB7 ■ 


PB6 


PBS 


PB4 


PB3 


PB2" " 


PBl , ■ 


PBO, 


R/W 


0X2 


DDRA 


DPA7 


DPA6 


DPA5 


DPA4 


DPA3 


DPA2 


DPAl 


DPAO 


R/W 


0X3 


DDRB 


DPB7 


DPS 6 ^ 


DPB5 


DPB4 


DPB3 


DPB2 


DPBl ^ 


DPBO - 


READ 


0X4 


TA LO 


T 

I 
M 

E, 
R 


TAL7 


TAL6 


TAL5 


TAL4 


TAL3 


TAL2 


TALI ' 


TALO 




READ 


0X5 


TA HI 


TAH7 


TAH6 


TAH5 


TAH4" 


TAH3 


TAH2" 


TAH1\. 


..TAHO'' 




READ 


0X6 


TB LO 


TBL7 


TBL6 


, TBL5 


TBL4 


TBL3 


TBL2 


TBLl- 


TBLO 


READ 


0X7 


TB HI 


TBH7 


TBH6" 


TBH5 


TBH4 


TBH3 , 


TBH2 


TBHl 


TBHO 


■ 


WRITE 


0X4 


TA LO 


P 
R 
E 
S 
C 
A 
L 
E 
R 


PAL7 


PAL6 


PALS 


PAL4 


■ PAL3 


■PAL2, 


PALI-' 


PALO 




WRITE 


0X5 


TA HI 


PAH7 


PAH 6 


PAHS 


PAH 4 


PAH3 


PAH2 


PAHl 


PAHO 






WRITE 


0X6 


TB LO 


PBL7 . 


PBL6 PBLo 


P3L4 


P3L3 


PBL2- 


PBLl 


PBLO 


1 




WRITE 


0X7 


TB HI 


"PBH7 . 


PBH6 


PBH5 


PBH4 


PBH3 


PBH2. 


■PBHI -. 


PBHO 


! 

■ ■ ; 
-1 




READ 


9C8 


TODATS 


T 

D 

T 
I 
M 
E 
R 


- 






. 





TA8 


TA4 


TA2 , 


TAl--"^,- 


- i 




READ 


0X9 


TODAS 


(*) 


SAH4 


SAH2 


"SAHl 


SALS 


SAL4' 


SAL2 


SALl 


'' :'. 




READ 


OXA 


TODAM 


f*) 


MAH4 .. 


MAH2 ■ 


MAHl 


MAL8 


MAL4- 


MAL2 . ■ 


MALI 


■ I 
' i 




READ 


OXB 


TODAH 


APM 
(*) 




IN TES1 



MODE: 


HAH 

WILL RE 


HAL8 ■ 
AD DIV] 


HAL4 

DER st; 


HAL2 MALI 
iGE OUTPUTS 


■-■.: 1" 




WRITE 


0X8 


TODATS 


T 

D 

L 

A 

T 

C- 

H 

E 

S 











,0 


TAB 


- TA4 


TA2 


TAl 




WRITE 


0X9 


TODAS 





SAH4 


SAH2 


SAHl ■ 


SAL8 


SAL4 


SAL2 


SALl 




WRITE 


OXA 


TODAM 





MAH4 


MAH2 


MAHl 


MAL8 


MAL4 


MAL2 


MALI 




WRITE 

1. M.iL 


OXB 


TODAH 


APM 

IF CR 

IF CR 

1 




B MARM 

B ALARM 

1 




BIT=1 

BIT=0 
1 


HAH 

, ALARM 

, TOD R 

1 


HAL 8 

REGIST 

EGISTEB 
1 


HAL4 

ER IS W 
IS WRI 


HAL 2 

RITTEN 
TTEN 


HALl 


' 














REGISTE 
T 


R BIT A 
ABLE 2 


LLOCATI 


ON 











Sy 


stent S 
R/W 


peci 
REG 


fication for C65 
NAME D7. 


D€ 


Fred 
D5 


Bowen 
D4 


D3 


>■■ March li 
D2 Dl 


DO v-n 


R/W 


oxc 


SDRA 


SRA7, 


SRA6 


SRA5 


SRA4 


SRA3 


SRA2 


SRAl 


SRAO 


■4 

* 

,:■- ' 

; .■;,-. 

■-.(■' 
" ■■--*-,■ 

, -^ 

f 

i 

•:i-,r 

1/ 

■■:".' 


READ 


OXD 


ICRA 

(INT DATA) 


IRA 








FLGA 


SPA 


AT.RMA 


TB 


TA ' 


WRITE 


OXD 


ICRA 
(INT MASK) 


AS/C~ 


— — 


— - ■ 


FLGA 


SPA 


AT.RMA 


TB 


TA ' 

^1 


R/W 


OXE 


CRA 


TODA 
IN 


SPA 
MODE 


TMRA 
INMODE 


LOADA 


RUN-A 
MODE 


•OOt-a 

MODE 


PRB6 
ON 


STARTA 


R/W 


OXF 


CRB 


ALARM 
(TODA) 


TIMERB 
CRB6 


INMODE 
CRB5 


LOADB 


RUN-B 

MODE 


OUT-B 
MODE 


PRB7 ■ 

ON : 


STARTS 


READ 


1X0 


PRC 


PC7 ' 


PCS 


PCS 


PC4 


PC3 


PC2 


PCI 


pco :; 


R/W 


1X1 


PRD 


PD7 ' 


PD6 


PD5 


PD4 


PD3 


PD2 


PDl 


PDO'^^^;: 


R/W 


1X2 


DDRC 


DPC7 


DPC6 


DPC5 


DPC4 " 


DPC3- 


DPC2 


PPGl 


DPCO 


R/W 


1X3 


DDRD 


DPD7 


DPD6 


DPD5 


DPD4 


: DPD3 


DPD2 


DPDl 


■DPDO 


READ 


1X4 


TC LO 


T 
I 

M 
£ 
R 


TCL7 


TCL6 


TCL5 


TCL4 


TCL3 


TCL2 


TCLl 


TCLO 


READ 


1X5 


TC HI 


TCH7 


TCH6 


TCH5 


TCH4 


TCH3 


TCH2 


TCHl 


TCHO 


READ 


1X6 


TD LO 


TDL7 


TDL6 


TDL5 


TDL4 


TDL3 


TDL2 


TDLl 


TDLO 


READ 


1X7 


TD HI 


TDH7 


TDK 6 


TDK? 


TDH4 


TDH3 


TDH2 . 


TDHl 


TDHO 


WRITE 


1X4 


TC LO 


P 
R 

E 
S 
C 
A 
L 
£ 
R 


PCL7 


PCL6' 


PCL5 


PCL4 


PCL3 


PCL2 


PCLl 


PCLO 


WRITE 


1X5 


TC HI 


PCH7 


PCH6 


pcas 


PCH4 


PCH3 


PCH2 


PCHl 


PCHO 


WRITE 


1X6 


TD LO 


PDL7 . 


PDL6 


PDL5 


PDL4 


.PDL3 


PDL2 


PDLl 


PDLO 


WRITE 


1X7 


TD HI 


PDH7 


PDH6 


PDH5 


PDH4 


PbH3 


PDH2 


PDHl 


PDHO . 




READ 


1X8 


TODBTS 


T 

D 

T 
I 
M 

E 
R 














■ T?8 


TB4 


TB2 


TBI 


READ 


1X9 


TODBS 


(*) 


SBH4 


SBH2 


SBHl 


SBL8 


SBL4 


SBL2 


SBLl 


■ 


READ 


IXA 


TODBM 





MBH4 ■ 


MBH2 


MBHl 


MBL8 


MBL4 


MBL2 


MBLl 


- 


READ 


IXB 


TODBH 


BPM . 
(*) 



IN TEST 



MODE: 


HBH 
WILL RE 


HBL8 

AD Div: 


HBL4 
DER STA 


HBL2 
GE OUTP 


HBLl 
UT 



REGISTER BIT ALLOCATION 
TABLE 2 (CONT'D) 



Sy 


stem S 
R/W 


peci 
REG 


ficatibn for C65 ;=' 
Na^ffi: d7 


^' ■'■'":*■ "'.v . Fxed'Bowen^:- 

D6 D5 D4 D3 


March 1, 
D2 Dl 


1991"/^ W 
DO f>u 


WRITE 


1X8 


TODBTS 


T 

D 

L 
A 
T 
C 
' H 
■£■ 
S 














.TB8 


TB4 


TB2 


TBI 




WRITE 


1X9 


TODBS 





SBH4 


SBH2 


SBHl 


SBL8 


SBL4 


SBL2 


SBLl 


■f;' : 

""':■■ .■! 
-1 

i 
■■■I' 

->'[■ 

.... - 1 . 

' I 

1 


WRITE 


IXA 


TODBM 





MBH4 


MBH2 


MBHl 


MBLB 


MBL4 


MBL2.' 


■MBLI*: 


WRITE 


IXB 


TODBH 


BPM 

IF C 
IF C 




RD ALARJ 
RD ALARi 




4 -BIT=1 
VI BIT=*0 


HBH HBL8 HBL4 HPL2 - 

■/ ALARM REGISTER IS WRITTEN 

, TOD REGISTER IS WRITTEN 
-1 ' ' ' 


■ HBLl'.,.- 


R/W 


IXC 


SDRB 


-SRB7 


SRB6 


SRBS: 


SRB4 


SRB3 : 


SRB2 


SRBl . 


: 

'-^SRBO'- 


READ 


IXD 


ICRB. 
{INT DATA) 


IRB ; 








FLGB 


SPB- 


. ALRMB 


, TD . ' 


'■kTC::i:. 


WRITE 


IXD 


ICRB 
{INT MASK) 


BS/C~ 


'" ~ 


. .'■ — , 


FLGB 


SPB - 


ALRMB 


TD . 


'■:,lTtt;i 


R/W 


IXE 


CRC 


■ TODB 
IN 


SPB 

MODE 


TMRC 
INMODE 


LOADC 


RUN-C 
: MODE 


OUT-C 

MODE 


PRD6 
ON , ■ 


STARTC 


R/W 


IXF 


CRD 


ALARM 
(TODB) 


TIMERD 
-CRD 6 


INMODE 

CRD5 


LOADD 


RUN-D 
MODE 


OUT-D 

MODE 


PRD7 
ON 


STARTD- 


"READ 

(rece: 


2X0 

:vE I 

1 


DREG 
)ATA REG) 


RCV7 


RCV5 


RCV5 


_ RCV4 


RCV3 ■ 


RCV2 


RCVl 


RCVO 


WRITE 
{TRANS 


2X0 

;mit 


DREG 
DATA REG) , 


XMT7 


XMT6 


XMT5. 


XMT4 


XMT3 


XMT2 


XMTl 


XMTO 


READ 


Vii 


URSR 


TDONE 


EMPTY 


ENDT- 


IDLE 


FRME ■ 


PRTX 


OVR 


FULL 


WRITE 


2X1 


URSR 


— 


— ". 


ENDT 


IDLE 


— 


■ — 


,_ 


-_ ■" 


R/W 


2X2 


URCR 


XMITR 

EN 


RCVER 
EN 


UART ' 
UMl 


MODE 
UMO 


CHAR I 
' CHI 


ENGTH 
CHO 


PARITY 
EN 


PARITY 
EVEN 


R/W 


2X3 


BRLO ' 


BRL7" 


BRL6 


BRX5 


BRL4 


BRL3 


BRL2 


BRLl 


BRLO 


R/W 


2X4 


BRHI 


BRH7 


-BRH6 


BRH5 


BRH4. 


BRH3 


BRH2 


BRHI 


BRHO 


R/W 


2X3 


URIEN 


XDIRQ 


RDIRQ 


XDNMI 


RDNMI 


— ■ 


i '" 




— 


READ 


2X6 


URIFG 


XDIRQ 


RDIRQ 


XDNMI 


RDNMI 




■ — 


— 


— 




R/W 


2X7 


PRE 


— 


— 


— 


— 


-- 




PEl 


PEG 


R/W 


2X8 


DDRE 


— 


— 


— 




— 


— 


DPEl 


DPEO 


. 


R/W 2X9 


F SERIAL 


*DMODE 


*FSDIR 


— 


— 


— 


— 


— 


-- 


i 












R 


EGISTER 
T 


BIT AL 
ABLE 2 


LOCATIO 
(CONT'D 


N 
) 






■ 


i 



System Specification for, C 65 
2.3.4 Memory Mapper 



■u XV >f 



Fred Bowen 



March l,t;X99i 




instrJ^loTsrillTiri;.tire ^L^li^^y^f?^^^ "^^^ -e additional 

and thI^?^^f^^5A^"*? (augment) opcode has been changed to MAP (mapperi ^ 
letencef?^^^ ""^^ (no-operation), has been changed to EOM (endiol^^apping- .- 

-' - ■.■.-■.-■ „ ^I^. 

ir.««=K J^® J^^° memory mapper allows the microprocessor to access uid i-o i ' t' 

much larger memory, within the S4K byte confinement window! ^ -"^."^.l-A 



it 



regxon, and blocks 4 through 7 are in the 



'upper" region 



'lower' 
as shown 






UPPER REGION ■ 



LOWER REGION ■ 



BLK 


7 


BLK 


6 


BLK 


5 


BLK 


4 


BLK 


3 


BLK 


2 


- BLK 


1 


BLK 






FFFF 

EOOO 

CO 00 

AOOO 

8000 

6000- 

4000 

2000 








Each block can be .programmed to be "maoDf^rt" m- "n^r, «,-,«««jn 

^i^%^.^^%s^?-nn:'-i];:kii?^t?ere~M ir rl" ^?"- ■■ 

when th^®r,^^iL^^^ ^"^ output; (NOMAP) which lets the outside world know 



System Specification for C65 



Fred ■ Bowen 



March 1, 1991 



4.V, "^^ ^S P'?^®^^-^!' ^"^ likely, to have mapped, and unmapped memory at 
the same physical address. And, with offset registers set to zero, mapped 
addresses will match unmapped ones. The only difference is the NOMAP sianal 
to tell whether the address is mapped or unmapped. signal 

To program the mapper, the operating system must load the A X Y ■ 
and Z registers with the following information, and execute a MAP opcod4. 



Mapper Register Data 
5 4 3 



V 



LOWER 
OFF 15 


LOWER 
OFF 14 


LOWER 

0FF13 


LOWER 
0FF12 


LOWER 

OFF 11 


LOWER 
OFF 10 


LOWER 
OFF 9 


LOWER 
OFF 8 


MAP 
BLK3 


MAP 
BLK2 


•MAP 
BLKl 


MAP 
BLKO 


LOWER 

OFF 19 


LOWER 
0FF18 


LOWER 

OFF 17 


LOWER ■ 
OFF 16 


UPPER 
OFF 15 


UPPER 
0FF14 


UPPER 
0FF13 


UPPER 
OFF 12 


UPPER 

OFF 11 


UPPER 

OFFIO 


UPPER 
OFF 9 


UPPER 
OFF 8 


MAP 
BLK7 


MAP 
BLK6 . 


MAP 
BLK5 


MAP 
BLK4 


UPPER 
0FF19 


UPPER 
OFF 18 


UPPER 
OFF 17 


UPPER 
OFF 16 



BIT 
A 



After exscuting the MA^ ococde, all ir.t-rru"T:s ar- inhibited Th^ s 

'^..tl'i^ fLJ■^i^^^!?^''^^''^^'-''^ ^^^^^"^ - -o^Piete'a mapping seouence 
without fear of getting an interrupt. An interrupt occurring before the 
proper stack-pointer is set will cause return addLs. -r.ata t? bl °^itten 
to an undesired area. --xute.i 



^h. ■ ^P^^^'^^Pljting the mapping seqiience, the operating system 
the^inter..fcpT: inhibit by executing a EOM (formerly NOP) opcode. 
a_.p^ication soitware may execute NOPw ui+-h n^ o-p^^^-t- 



may execute NOPs with no effect. 



must remove 
Note that 



System Specification for C65 p^^^ r^, 

Fred Bowen March 1, 1991 

^•^'^ Peripheral Control T>„r.^4»»^ 
2.3.5.1 I/O Ports 

and -nT^it'^ltTLl^t^^^^^^^^ ?-ta Register (PR) 

and DDR registers. If a bit ?n f^f nnS^* * £°^^ ^ consists of a 2-bit PR 

prov.de t.n.e. output functions ir/f..To°CorXTol'lT^hlTslltil^\'tl 
bits Tu^l^il Ifalltr^Z t'n l^\'.,TotLT ^'°^^ ^-"^P"=.n. The othex 

""" "low-1'"' " ^ "^'^^" " it'= configured as input (DPC4 is a 

^ffL°St"srp^:^-r::^, <?L"vi!ue^ :i;L^';kT"^^^^^ -i^^ .. 

the PRC4e pin is pulled "low" ?f Iclis "hiah"- o^h '^^ ^^^" 
PRC46 is pulled-up through passive resfstor^ ' °^'^""^^^' 

^" -lo5"?t^ '' " "''^5^" ^^ it's configured as input (DPC5 is a 
If configured as output (DPC5 is a "Viirr>i"i ^-v« -u-^ 

PRC57 is pulled-up through passive resfstSr' ' °^^"""«' 

PC6,PC7 I^^^,\^it|fe always configured as inputs. When PORT C ,PRC, 
PRC57 pins, respectively! ^^^ ''^^"^^ °" ^^^ ^^^^.^ and 

2.3.5.2 HandshaJcincj 

Pin a^rl^^h^^rihe%S|^/%Tlfl^|/-pS? IST'^i^l^ril^ ^^?,-^/ -tP- 
and stay low for two cycles, two cycles after';, l^t/ ^^"^ ''^^^ ^° 1°" 
This is required to meet Centronics Para?fe!lnterface^,«^^^^ l^ ^^^^ °- 
can be used to indicate "data ready" at PORT n ^^ "S ? ^^^""^ * ^^^ ^^/ ^^^e 
D. Handshaking on 16--bit data transfers ?u^iLf*r^^\S'=''^P^^^" ^^^"^ ^0^^ 
PORT D) is possible by always reaSng or wrftina POR?^ """"^n.?^ ^ ^^^ t^«" 



System Specification for C65 Fred Bowen March 1, 1991 

2.3.5.3 Interval Timers (Timer A, Timer B, Tiiper C, Tijmer D) 

Each interval timer consists of a 16-bit read-only Timer Counter and a 
16-bit write-only Timer Latch (prescaler) . Data written to the timer are 
latched in the Timer Latch, while data read from the timer are the present 
contents of the Timer Counter. The timers can be used independently or - 
linked in pairs for extended operations (TIMER A may be linked with Timer B; 
TI^iER C may be linked with TIMER D) . The various timer modes allow genera- 
tion of long time delays, variable width pulses, pulse trains and variable 
frequency waveforms. Utilizing the CNT inputs, the timers, can count exter- 
. nal pulses or measure frequency, pulse witdth and delay times of external 
signals. Each timer has an associated control register, providing indepen- 
dent control of the following functions (see bits functional description in 
section 2,5.8 below): 

Start/Stop 

Each timer may be started or stopped by the microprocessor at any time 
by writing to the START/STOP bit of the corresponding control register (CRA,- 
CRB, CRB or CRC) . 

PRB, PRD On/Off 

Control bits allow any of the timer outputs to appear on a PORT B or 
PORT D output line (PRB6 for TIMER A, PRB7 for TIMER B, PRD6 for TIMER C 
and PRD7 .for TIMER D) . Note that this funtion overrides the DDRB control 
bit and forces the appropiate ?B or ?C line to be: an output. 

Toggle/Pulse 

Control bits select the ouputs applied to PORT B and PORT D. On every 
timer underflow the ouput can either toggle or c ^ 7:-r-:.r. =; ?- :~ingle positive 
pulse of one cycle duration. The Toggle output is set high whenever the 
appropiate timer is started and is set low by RESET/. 

One- Shot /Cent inuous 

Control bits select -either timer mode. In one-shot mode, the timer 
will count down from the latched value to zero, generate an interrupt, 
reload the latched value, then stop. In continuous mode, the timer will 
count from the latched value to zero, generate an interrupt, reload the 
latched value and repeat the procedure continuously. 

Force Load 

i 

A strobe bit allows the timer latch to be loaded into the timer 
counter at any time, whether the timer is running or not. 

Input Mode 

Control bits allow selection of the clock used to decrement the timer. 
TIMER A or TIMER C can count C1MH2 clock pulses or external pulses applied 
to the CNTA or CNTB, respectively. The CIMHZ clock is obtained after in- 
ternally dividing the C7MHZ by a factor of seven. 

TIMER B can count CIMHZ clock pulses, external pulses applied to the 
CNTA input, TIMER A underflow pulses or TIMER A underflow pulses while the 
CNTA pin is held high. 



System Specification for C65 p^«^ n 

TIMER D can count ClMHZ clock nfJ=?c ? i i "^^^^ i' 1991 
CNTB input, TIMER C underflL i.^? Pulses, external pulses applied to the 
CNTB pin is held high ^""^^^^ °^ ^^^^ ^ underflow pulses while the 

force^load'or^follSwing l"itlte'T^l''\^^^'^ °" ^"^ ^^^^^ underflow, on a 
timer i. stopped. if ?he timer is runn^.^^ byte of the prescaler whiirthe 
load the time? latch, but noTreloaS'^Se^IiuSt^r!^^ ^° ^^^ ^^^^ .^^^^ -^^ 

^•^•^•'^ Time of D ay Clocks (TODA. TODR^ 

wjth X/lOth second resolution Each ?s'o?aanized fnr^ ^'"""""^ .'^/^«' '=i°=J= 
of seconds (TODATS, TODBTS) , Seconds aoSIl roDBql m- "?'' registers: lOths 
and Hours (TODAH, TODBH) The AM/pm <=t = ^ ' ™°SS) , Minutes TODAM, TODBM) 
register for eas^ testing Elch^rlaif^S^ "-^ i" ""^^ "^^ °^ ^^^ Hours ' 
fy conversion for driving -dispfayr^elc Each %on^ " ^'^° ^°""^t ^° ^i'"?! 
input to keep accurate timing This 10H7 ?fS^,,^°° requires a lOHZ clock 
the C7MH2 clock input by a Alitor of 1^277^? m^=?^'??S"^'^ ^^ dividing 
a factor of 101339 for IaL (t^Hzf applicf t fnn^ "tk*^ i^°"5' application!, or 
selected by the TODA IN and thi TOM IN S?^?^; The divider ratio is 
and CRC, respectively (see 2:5 8) Control Registers, CRA 

rating\f inte^rup? at'"the'I?^?4d\?m^^"?"™"'='^ ^^^^ " P--=^-^ f- gene- 
ALARM registers registers are^ocfted at iht\ttt^^^^^°^ ^^^ ^°° clocks.' The' 
spending TODA and TODB register? a^.fL "ff"^ addresses as the corre- 

in the control Hegisters'?Rf and ' CrS'^IL^L^^M ^^T..'' '°"^^"^=^ ^^- ^^' ^ 

tI:L^^a^cefs^L°?ro1\^^L^"^^^ -^^ ti.e^'^?e^^^^e;|-f t^^l s-atr^rt'Sf -• 

readi^g^?l1f j,= ^Sg^^^fTSD^ fr^^t^lSa^Lallv'^s^""^'^/".^ ^"^^ ^"-5 and 
corresponding Hours register occurs The TOD^??^:"'^?^^^^ ^ "^^^^ to the 
after a write to the proper lOths of JnnnH= ^ ""'^ ^^^''t ^^ain until 
TOD will always start at the desired ti^^ %"^^^^^''- ^""^^ assures that a 
the next can occur at any time with resSlit f^"" ^ S^^^^ ^^°"' °"^ ^tage to 
function is included to Leu airiime If Sav ?n? ^=^5. °P^ration, a latching 
reaa sequence. All four registers of efch TOD f^?!!!^''^"" <=°"^tant during a^ 
corresponding Hours registe? and Lmf^S ?^- P..-'-"^^ °'^ = read of the 
corresponding lOths of 'second reg"?er A TOD con^"' ^'\" ^ "^^ °^ the 
output registers are latched. If onlv'on^ ^?°< fJ^^inues to count when the 
no carry problem and the register can h^^^fw^i^^^fu^^.to be read, there is 
any read of the Hours regisfeflf ?clloweS h5 1 ^^^ t^^" ' Provided that 
seconds, to disable the latching? ''°-^-^°"^'^ ^y ^ read of bhe proper lOths of 

2-3,5.5 Serial Por ts (SDRA. gnpm 

Each serial port is a bufferoH a Kit- 
ten,. A control bit (CRA SPA bit CRC SPB hfJ'? f"'!?^ ^^'^"^ register sys- 
for either the SDRA or SDRB port. ' selects input or output mode 

sponding'Sgfft"^^^i3t'er\rthe%f:Lre^a! '''f\t' ^'"^^^ ^"^o the corre- 
or CNTB pin, respectively. Alter 8 CN?A^o„?Lc''^ fi^"2^ applied to the CNTA 
register is dumped into ?he SE^!I^ D^^t^^ ^^^^ (SDRATand-a^^fnte^^^^pt is 



System Specification for C65 Fred Bowen March 1, 1991 



generated, SPA bit is set in register ICRA. After 8 CNTB pulses , the data 
in the shift register is dumped into the SERIALB Data Register (SDRB) and an 
interrupt is generated, SPB bit is set in register ICRB.- 

In the output mode, TIMER A is used for the baud rate generator of 
serial port A, Timer C for serial port B. Data is shifted on an SP pin at 
half the underflow rate of the TIMER used. The maximum baud rate possible 
is ClMHz divided by four, but the maxiimum useable baud rate will be deter- 
mined by line loading and the speed at which the receiver responds to input 
data. Transmission will start following a write to Serial Data Register 
(provided the proper TIMER used is running and in continuous mode) . The 
clock signal derived from TIMER A would appear as an output on the CNTA pin; 
the one from TIMER C would appear otn the CNTB pin. The data in the Serial 
Data Register will be loaded into its corresponding- shift register then 
shift out to the SPA or SPB pin when a CNTA or CNTB pulse occurs, respec- 
tively. Data shifted out becomes valid on the falling edge of its CNT clock 
and remains valid until the next falling edge. After 8 CNT pulses, an 
interrupt is generated to indicate more data can be sent. If the Serial 
Data Register was loaded with new information prior to this interrupt, the 
new data will automatically be loaded into the shift register and transmis- 
sion will continue. If the microprocessor stays one byte ahead of the shift 
register, transmission will be continuous. If no further data is to be 
transmitted, after the 8th CNT pulse, CNT will return high and SP will 
remain at the level of the last data bit transmitted. SDR data is shifted 
out MSB first and serial input data should also appear on this format. 

The bidirectional capability of each of the Serial Ports and CNT clocks 
allows many 4510 to be connected to a common serial communication bus on 
which one Serial Port would act as a master, sourcing data and shift clock, 
while the other Serial Port (and all other ports from other 4510 devices) 
would jact as slaves. All the CNT and SP outputs are open drain to allow 
such a common bus. Protocol. for master/slave selection can be transmitted 
over the serial bus, or via dedicated handshaking lines. 



System Specification for C65 Fred Bowen March 1, 1991 

2.3.5.6 FAST SERXAI. MODE 

The FAST SERIAL logic consists of a 2-bit write-only register, which 
resides in location 0001 (hex) . This register may only be accessed by the 
CPU if neither the AEC or DMA/ line is low. Upon reset, both bits in the 
register are forced low which allows the device to operate as normal (the 
CNTA, SPA, PRC57 and FIAGA/ lines will not be affected) . 

Bit 7 of the FAST SERIAL register is the Fast Serial Mode disable bit 
(DMODE* bit) . 

Bit 6 of the FAST SERIAL register is the FSDIR* bit. When the DMODE* 
bit is set high, the FSDIR* bit will be used as an output to control the 
fast serial data direction buffer hardware, and as an input to sense a fast 
disk enable signal. This function will affect the CNTA, SPA, PRC57 and 
FLAGA/ lines as summarized in the following table. 

DMODE* FSDIR* ' FUNCTION 

Fast Serial mode is disabled. 

X 1 Both the FLAGA/ and the PRC57 lines will behave 

as outputs. The FLAGA/ output will reflect the 
state of the CNTA pin, whereas the PRC57 output 
will reflect the state of the SPA pin. 

1 Both the CNTA and SPA lines will behave as 

outputs. The CNTA ouput will reflect the state 
of the FLAGA/ pin, whereas the SPA output will 
reflect that of the PRC57 pin. 



System Specification for C65 Fred Bowen March I 1991 

2.3.5.7 Interrupt Control Registers (ICRA, ICRB) 

These registers control the following sources of interrupts: 

i. Underflows from TIMER A, TIMER B, TIMER C and TIMER D 

ii. TODA ALARM and TODB ALARM, 

iii. SERIALA and SERIALB Port full/empty conditions.^ 

iv. FLAGA/ and FLAGS/ low transitions. 

The ICRA and ICRB registers each provides masking and interrupt infor- 
mation. ICRA and ICRB each consists of a write-only MASK register and a 
f^'i^^^i^'^^'^^ register. Any interrupt will set the corresponding bit in 
tne DATA register. Any interrupt which is enabled by the MASK register will 
set the IR bit (MSB) of its corresponding DATA register and bring the IRQ/ 
pin low. In a multi-chip system, the IR bit (IRA of ICRA or IRB of ICRB) 
can be polled to detect which chip has generated an interrupt request. The 
interrupt DATA register is cleared and the IRQ/ line returns high following 
a read of the DATA register. Since each interrupt sets and interrupt bit ■ 
regardless of the MASK, and each interrupt bit can be selectively masked to 
prevent the generation of a processor interrupt, it is possible to intermix 
polled interrupts with true interrupts. However, polling either of the IR 
f will cause its corresponding DATA register to clear, therefore, it is 
up to the user to preserve the information contained in the DATA registers 
It any polled interrupts were present. 

Both MASK (ICRA, ICRB) registers provide convenient control of indivi- 
dual mask bits. When writing to a MASK register, if bit 7 of the data 
written (corresponding to AS/C in ICRA, or BS/C in ICRB) is a ZERO, any 
^^^^^^^-Vr^^^" ^J^^ ^ T^ "ill ^^ cleared, while those bits written with 
a zero will be unaffected. In order for an interrupt flag to set the IR bit 
and generate an Interrupt Request, the corresponding MASK bit must be set in 
the corresponding MASK Register. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.3.5.8 Control Registers (CRA, CRB, CRC, CRD) 



CRA 

BIT 



(OXE): 
Bit Name 

STARTA 



PRB6 ON 



OUT-A MODE 



RUN«A MODE 



CRB 

BIT 



LOADA 



TMRA INMODE 



SPA MODE 



TODA IN 



(OXF) : 
Bit Name 



Function 

1=START TIMER A, 0=STOP TIMER A. This bit is automat- 
ically reset when TIMER A underflow occurs durino one- 
shot mode. 

1=TIMER A output appears on PRB6, 0=PRB6 normal port 
operation. 

1=T0GGLE output applied on port PRB6, 
0=PULSE output applied on port PRB6. 

1=0NE-SH0T TIMER A operation, 
O^CONTINUOUS TIMER A operation. 

1-FORCE LOAD on TIMER A (this is a STROBE input, there 
xs no data storage, bit 4 will always read back a zero 
and writing a zero has no effect) , 

1=TIMER A counts positive CNTA transitions, 
0=TIMER A counts internal CIMHZ pulses. 

n-lf^T^^ ? nSE output mode (CNTA sources shift clock), 
0-SERIAL A PORT input mode (external shift clock on CNTA) 

1=50 Hz operation. C7MHZ divided down by 101339 to oene- 
rate TODA input of 10 Hz. ^ 

rite" ?SD^^fS5SVSf iVT "'"''"'* =*°"" '^^ '°'''' ^° 5-- 



Function 



(Bits 0-4 of the CRB register operate identically to bits 0-4 of the CR7 



5,6 



TIMERB 

INMODE 



Bits 5 and 6 select one of four input modes for TIMER B 
as follows: 

CRB6 CRB5 * 

TIMER B counts ClMHz pulses. 

1 TIMER B counts positive CNTA transitions. 

1 TIMER B counts TIMERA underflow pulses. 

1 1 TIMER B counts TIMERA underflows while CNTA is high. 



ALARM TODA 



l=writing to TODA registers sets ALARM, 
O^writing to TODA registers sets TODA clock, 



System Specification for C65 



Fred Bowen 



March 1, 1991 



CRC (IXE) : 
BIT Bit Name 

STARTC 



Function 

1=START TIMER C, 0=STOP TIMER C. This bit is automat- 
ically reset when TIMER C underflow occurs during one- 
shot mode . 



1=TIMER C output appears on PKD6, 0=PRD6 normal port 
operation. 

1=T0GGLE output applied on port PRD6, 
0=PULSE output applied on port PRD6. 

1=0NE-SH0T TIMER C operation, 
0«CONTINUOUS TIMER C operation. 

1=F0RCE LOAD on TIMER C (this is a STROBE input, there 
is no data storage, bit 4 will always read back a zero 
and writing a zero has no effect) . 

TMRC INMODE 1=TIMER C counts positive CNTB transitions, 
0=TIMER C counts internal CIMHZ pulses. 

1=SERIAL B PORT output mode (CNTB sources shift clock) , 
0=SERIAL B PORT input mode (external shift clock on CNTB) 

1=50 Hz operation. C7MHZ divided down by 101339 to gene- 
rate TODB input of 10 Hz.. 

0=60 Hz operation. C7MHZ divided down by 102273 to gene- 
rate TODB input of 10 Hz 



1 


PRD6 ON 


2 


OUT-C MODE 


3 


RUN-C MODE 


4 


LOADC 


5 


TMRC INMOD 


6 


SPB MODE 


7 


TODB IN 



CRD (IXF) : 
BIT Bit Name 



5,6 



Function 



(Tits 0-4 of the CRD register operate identically to bits 0-4 of the CRD 
register, except that functions now apply to TIMER D and bit 1 controls 
the output of TIMER D on PRD7) . 



TIMERD 
INMODE 



Bits 5 and 6 select one of four input modes for TIMER D 
as follows: 



CRD6 CRD5 

TIMER D counts ClMHz pulses. 

1 TIMER D counts positive CNTB transitions. 

1 TIMER D counts TIMERC underflow pulses. 

1 1 TIMER D counts TIMERC underflows while CNTB is high. 



ALARM TODB 



l=writing to TODB registers sets ALARM, 
0=writing to TODB registers sets TODA clock. 



System Specification for C65 Fred Bowen 

C65 Peripheral Control Dtilization 



March 1, 1991 



6526 cia complex interface adapter #1 

keyboard / joystick / paddles / mouse / lightpen / fast serial 



praO 


keybd 


pral 


keybd 


pra2 


keybd 


pra3 


keybd 


pra4 


keybd 


pra5 


keybd 


pra6 


keybd 


pra7 


keybd 


prbO 


keybd 


prbl 


keybd 


prb2 


keybd 


prb3 


keybd 


prb4 


keybd 


prb5 


keybd 


prbfi 


keybd 


prb7 


keybd 


timer 


1 & era 


timer 


2 & crb 


tod 




sdr 




Acr 





output cO / joystick #1 up 
output cl / joystick #1 down 
output c2 / joystick #1 left 
output c3 / joystick #1 right 
output c4 / joystick #1 fire 
output c5 / 
output c6 / 
output c7 / 



/ mouse right button 



/ paddle "A" fire button 
/ paddle "B" fire button 
/ mouse left button 



/ select port #1 paddles {mouse 
/ select port #2 paddles Imouse 



input rO / joystick #2 up 

input rl / joystick #2 down 

input r2 / joystick #2 left 

input r3 / joystick #2 right 

input r4 / joystick #2 fire 

input r5 / 

input r6 / timer b: toggle/pulse output 

input r7 / timer a: toggle/pulse output 

: fast serial 



/ mouse right button 

/ paddle "A" fire button 

/ paddle "B" fire button 

/ mouse left button 



6526 cia complex interface adapter #2 

user port / rs232 / serial bus / V^ bank / NMI 



praO 

pral 
pra2 
pra3 
pra4 
praS 
pra6 
pra7 

prbO 
prbl 
prb2 
prb3 
prb4 
prb5 
prb6 
prb7 



val4 
valS 
rs232 

serial ATN 
serial CLK 



VIC 16K bank select 



DATA output 
output 
output 
serial DATA output 
serial CLK input 
serial DATA input 

user port / rs232 received data 
user port / rs232 request to send 
user port / rs232 data terminal ready 
user port / rs232 ring indicator 
user port / rs232 carrier detect 
user port 

user port / rs232 clear to send 
user port / rs232 data set ready ■ 



(C64 mode only) 



(C64 mode only) 



timer 1 & era 
timer 2 £ crb 



rs232 baud rate 
rs232 bit check 



{C64 mode only) 
(C64 mode only) 



tod 
sdr 
icr 



nmi (/irq) 



System Specification for C65 
2.3.6 XJKRT Operation 



Fred Bowen 



March 1, 1991 



The device contains seven registers to control the different UART 
modes of operation. Section 2.2 describes how to access these registers 

The UART modes can be programmed by accessing the UART control 
register, UKCR, whose bits function as described below. 



2.3.6.1 TJART Control Register fURCR) 
BIT Bit Name Function 

PARITY EVEN 1-Even Parity. If parity is enabled, the transmitter 

will assert the parity bit (P) to a low when "even" pari- 
ty data xs transmitted, otherwise it will pull it high 
The receiver checks that the parity bit is asserted, 
or low, if the data received has even parity; if the bit 
is not asserted, the device will indicate a parity error. 

O=0dd Parity. " If parity is enabled, the transmitter 
will pull the parity bit (P) low,- when "odd" parity data- 
is transmitted, otherwise it will pull it high. The 
receiver checks that the parity bit is asserted if the 
data received has odd parity; if the bit is not asserted 
when data had odd parity, the device will indicate a 
parity error. 

1 PARITY EN 1= Parity Enabled. 

0= Parity Disabled. The transmitter and receiver will not 
allocate a parity bit in the data, instead a stop bit 
will be used in its place. See the Data Configuration 
chart below, 

2,3 ^HAR LENGTH These two bits are used to select the number of bits per 

character to be transmitted or received. 5,6,7 or 8 bits 
per character may be selected as follows : 



4,5 



UART MODE 



eight bits per character 

seven bits per character 

six bits per character 

five bits per character 

These two bits select whether operations will be 
asynchronous or synchronous for the transmitter 
and/or receiver. The actual selection is done as 
follows : 



DMl 

IT 



T3H0 
IT 



both transmitter and receiver 
operate in asynchronous mode. 

receiver operates in synchronous 
mode, transmitter in asynchronous 
mode . 

receiver operates in asynchronous 
mode, transmitter in synchronous 
mode. 



System Specification for C65 Fred Bowen March 1, 1991 

BIT Bit Name Function 

6 RCVIl EN 0= Receiver is disabled. 

1=5 Receiver is Enabled. To provide, noise immunity, the 
duration of a bit interval is segmented into 16 sub- 
intervals. This is also used to verify that a high to 
low transition (START bit) on the RXD line is valid 
(stays low) at the half point of a bit duration; if not 
valid, operation will not start. 

If after an idle period, a high to low transition is 
detected on the RXD line and is verified to be low, the 
receiver will synchronized itself to the incoming char- 
acter for the duration of the character. Received data 
is then sampled or latched in the center of a bit time to 
determine the value of the remaining bits. The LSB of 
the data is the leading bit received. Any unused high 
order register bits will be set "high". The receiver 
expects the data to have only one parity bit (when parity 
is enabled) and one stop bit. 

At the end of the character reception, the receiver will 
check whether any errors have occured and will update 
the status register (URSR) accordingly. In addition, if 
no errors were encountered the receiver will load the 
contents of the shift register into the Receiver Data 
Register, eliminating parity and stop bits. 

In synchronous mode, the receiver will reconfigure its 
Data Register and Shift Register so that only 8 data 
bits are always accepted on the RXD line. This mode 
only works if an external clock is applied on the PRC2 
input line, which is used to shift the bits into the 
Receiver Shift Register. Data on the RXD is latched at 
the rising edge of the external clock applied in PRC2. 

7 XMITR EN 0= Transmitter is disabled. 

!=_ Transmitter is Enabled. Transmitter will start opera- 
tion once the microprocessor writes data to the trans- 
mitter data register (DREG) , after which the Transmitter 
Shift Register is loaded and the start bit is placed on 
the TXD line. The LSB of the data is the leading bit 
being transmitted. The Transmitter is "doubled buffered" 
which means that the CPU can load a new character as 
soon as the previous one starts transmission, 
this is indicated by the status register, bit 6 (URSR6- 
EMPTY Data Register), which when set, it indicates that 
the data register is ready to accept the next character. 
The character data format is illustrated by figure 1,3. 

In synchronous mode, the transmitter will reconfigure its 
Data Register and Shift Register so that only 8 data 
bits are always transmitted on the TXD line, eliminating 
all parity and stop bits. The external clock output will 
be placed in the PRC2 line and will shift the data 
out of the transmitter shift register. Data on the TXD 
line will change on the falling edge of the PRC2 signal, 
the external clock. 



System Specification for C65 Fred Bowen 

2.3.6.2 VRRr Stat-us Register (URSR) 
BIT Bit Name Function 



March- 1, 1991 







FULL 



OVR 



PRTY 



FRME 



4 IDLE 



ENDT 



Receiver Data Register Full bit. This bit is forced to 
a low upon reset, or after the data register (DREG) is 
read. This bit is enabled only if the RCVER EN bit is 
set in the URCR register. The FULL bit is set when the 
character being received is transferred from the receiver 
shift register into the receiver data register. If an 
error is encountered in the character data, this bit will 
not be set and the proper error bit will be set in the 
URSR register. 

Receiver. Over-Run Error bit. This bit is cleared upon 
reset or after reading the receiver data register. This 
bit is set if the new received charater is attempted to 
be transferred from the receiver shift register before 
reading the last character from the data register. There- 
fore, the last" character is preserved in the data 
register while the new received character is lost. 

Receiver Parity Error bit. This bit is cleared upon 
reset or after reading the receiver data register. The 
PRTY bit will be set when a parity error is detected on 
the received character, provided the PARITY EN bit is set 
and receiver is running asynchronously. 

Receiver Frame Error bit. This bit is cleared upon 

reset or after reading the receiver data register. 

The FRME bit is set whenever the received character 

contains a low in the first stop-bit slot. 

Receiver Idle bit. When this bit is written to a "high", 
the status register bits 0-3 are disabled until the 
receiver detects 10 consecutive marks, highs, on the RXD 
line, at which time the IDLE bit is cleared. This bit is 
also cleared upon reset. This bit allows the micro- 
processor, or any external microprocessor device, to 
ignore the transmission of a character until the start 
of the next character. 

Transmitter End of Transmission bit. This bit is cleared 
upon reset or whenever data is written »Lnto the trans- 
mitter data register, DREG. Setting this bit would 
disable the Transmitter Empty bit, EMPTY, until device 
completes transmission. 



System Specification for C65 



Fred Bowen 



March 1, 1591 



2.3.6.3 Character Configuration 



ASYUC MODE 



MARK>^ 



S 
T B 

A I 
R T 

T LSB 



P= PARITY BIT 
STP= STOP BIT 





DO 


Dl 


D2 


D3 


D4 


P 


STP 


STP 



1 

1 



5-BIT/CHARACTER 





DO 


Dl 


D2 


D3 


D4 


D5 


P 


STP 


STP 





DO 


Dl 


D2 


D3 


D4 


D5 


D6 


P 


STP 


STP 


















DO 


Dl 


D2 


D3 


D4 


D5 


D6 


D7 


P 


STP 



6-BIT/CHARACTER 

7-BXT/CHARACTER 

8-BIT/CHARACTER 



■> 



DO 



Dl 



D2 



D3 



D4 



STP 



STP 



DO 



Dl 



D2 



D3 



D4 



D5 



STP 



STP 





DO 


Dl 


D2 


D3 


D4 


D5 


D6 


STP 


STP 










_ 






DO 


Dl 


D2 


D3 


D4 


D5 


D6 


D7 


STP 



5-BIT/CHARACTER 

6-BIT/CHARACTER 

< 7-BIT/CHARACTER 



STP 



CHARACTER CONFIGURATION 
TABI£ 3 



8-BIT/CHARACTER 



P 
A 
R 
I 
T 
Y 

E 
N 
A 
B 

L 
E 
D 

P 
A 
R 
I 
T 
Y 



-> D 

.1 
S 
A 
B 
L 
E 
D 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.3.6.4 Register Map 



C65 UART 
R/W REG NAME D7 D6 D5 D4 D3 D2 Dl DO 



R/W 





DATA 


R/X7 


R/X6 


R/X5 


R/X4 


R/X3 


R/X2 


R/Xl 


R/XO 


R 


1 


STATUS 


XMIT 

DONE 


XMIT 
EMPTY 


ENDT 
■ (R/W) 


IDLE 
(R/W) 


FRAME 


PARITY 


OVER 
RUN 


RCVR 

FULL 


R/W 


2 


CONTROL 


XMIT 
ON 


RCVR 
ON 


UART 


MODE 


WORD LENGTH 


PARITY 
ON EVEN 


R/W 


3 


BAUD LO 


BRL7 


BRLe 


BRL5 


BRL4 


BRL3 


BRL2 


BRLl 


BRLO 


R/W 


4 


BAUD HI 


BRH7 


BRH6 


BRH5 


BRH4 


BRH3 


BRH2 


BRHl 


BRHO 


R/W 


5 


INT MASK 


XMIT 
IRQ 


RCVR 
IRQ 


XMIT 
NMI 


RCVR 
NMI 


— 


— 


— 


— 


R 


'6 


INT FLAG 


XMIT 
IRQ 


RCVR ■ 
IRQ 


XMIT 
NMI 


RCVR 
NMI 


— 


— 




— 



System Specification for C65 Fred Bowen March. 1, 1991 

The BAUD RATE can be generated using the following formulas: 
URCLK URCLK 



BaudRate = 



or. 



COUNT = 



- 1 



Where: 



16 ( COUNT+1 ) 16 X BaudRate 

COUNT = value loaded into BAUD RATE register 
URCLK = C7Mhz input, 7.15909 MHz NTSC 

7.09375 MHz PAL 

The following tables show some of the most common data rates. 

Data rate errors of less than +/-1.5% are acceptable for most purposes 

A. NTSC URCLK = 7.15909 MHZ 



BR 


BAUD RATE 


COUNT 


BAUD RATE 


PERCENT 


# 


REQUIRED 


(HEX) 


OBTAINED 


ERROR 


1 


50 


22F4 


49.999 


.0015 


2 


75 


174D 


74.999 


.0015 


3 


110 


0FE3 


109.991 


.0080 


4 


134.5 


OCFE 


134.488 


.0090 


5 


150 


0BA6 


149.998 


.0015 


6 


300 


05D2 


299.895 


.035 


7 


600 


02E9 


599.79 


.035 


8 


1200 


0174 


1199.58 


.035 


9 


1800 


OOFS 


1796.96 


.17 


10 


2400 


OaB9 


2392.74 


.30 


11 


3600 


007B 


3608. 4i 


.23 


12 


4800 


005C 


4811.22 


.23 


13 


7200 


003D 


7216.82 


.23 


14 


9600 


002E 


? 9520.07 


.83 


15 


19200 


0016 


19454.0 


1.323 


16 


31250 


OOOD 


31960.2 


1.023 





56000 


0007 . 


55930.4 


.124 



(MIDI) 



B. PAL 



URCLK = 7.09375 MH2 



BR 


BAUD RATE 


COUNT 


BAUD RATE 


PERCENT 


# 


REQUIRED 


<HEX) 


OBTAINED 


ERROR 


1 


50 


22A2 


50.001 


.0020 


2 


75 


1716 


75.005 


.0080 


3 


110 


OFBE 


109.987 


.010 


4 


134.5 


OCDF 


134.514 


.010 


5 


150 


OB SB 


149.986 


.009 


6 


300 


05C5 


299.973 


.009 


7 


600 


02E2 


599.75 


.009 


8 


1200 


0170 


1198.27 


.144 


9 


1800 


OOFS 


1802.27 


.126 


10 


2400 


00B8 


2396.54 


.144 


11 


3600 


007A 


3604.55 


.126 


12 


4800 


005B 


4819.12 


.398 


13 


7200 


003D 


7150.96 


.68 


14 


9600 


002D 


9638.25 


.40 


15 


19200 


0016 


19276.5 


.40 


16 


31250 


OOOD 


31668.5 


1.01 





56000 


0007 


55419.9 


1.04 



(MIDI; 



System Specification for C65 Fred Bowen March 1, 1991 

2.3.7 CTU 

2.3.7.1 Introduction 

The 4502, upon reset, looks and acts like any other CMOS 6502 
processor, with the exception that many instructions are shorter or 
require less cycles than they used to. This causes programs to execute 
in less time that older versions, even at the same clock frecjuency. 

The stack pointer has been expanded to 16 bits, but can be used 
in two different modes. It can be used as a full 16-bit (word) stack 
pointer, or as an 8-bit (byte) pointer whose stack page is programmable. 
On reset, the byte mode is selected with page 1 set as the stack page - 
This is done to make it fully 65C02 compatible. 

The zero page is also programmable via a new register, the "B" or 
Base Page" register. On reset, this register is cleared, thus giving a 
_rue "zero" page for compatability reasons, but the user can define any 
'page in memory as the "zero" page. 

A third index register, "Z", has been added to increase flexability 
in data manipulation. This register is also cleared, on reset, so that the 
STZ instructions still do what they used to, for compatability. 

This is a list of opcodes that have been added to the 210 previously 
defined MOS, Rockwell, and GTE opcodes. 

1 . Branches and Jumps 

word- relative 
word- relative 
word-relative 
word-relative 
word- relative 
word-relative 
word-relative 
word-relative 
word-relative 

Branch to subroutine (word relative) 

Jump to subroutine absolute indirect 

Jump to subroutine absolute indirect, X 

Return from subroutine and adjust stack pointer. 

2. Arithmetic Operations^ i 

NEG A Negate (or 2's complement) accumulator. 

Arithmetic Shift right accumulator or memory 



Increment Word 
Decrement Word 

Increment and 
Decrement Z register 

Arithmetic Shift Left Word 
Rotate Left Word 

These were formerly (ZP) non-indexed 
now are indexed by Z register 
(when .Z=0, operation is the same) 





BCC 


label 




BCS 


label 




BEQ 


label 




BMI 


label 




HUE 


label 




BPi 

bA 


label 




label 




BVC 


label 




bvs 


label 




BSR 


label 


^ / 


JSR 


(ABS) 


— ■ 


JSR 


(ABS,X) 




RTN 


# 



ASR A 
ASR ZP 
ASR ZP,X 




INW ZP 
DEW ZP 




INZ 
DEZ 




ASW ABS 
ROW ABS 




ORA (ZP) 
AKD (ZP) 
EOR (ZP) 


Z 

rZ 



ADC CZP),Z 

CMP (ZP),Z 

' SBC (ZP) ,Z 

CP2 IMM Compare Z register with memory immediate, 

CPZ 2P zero page, and 

CPZ ABS absolute. 

3. Loads, Stores, Pushes, Pulls and Transfers 

LDA (ZP),Z formerly (ZP) 

LDZ IMM Load Z register immediate, 

LDZ ABS absolute, 

LDZ ABS,X absolute, X. 

LDA (d, SP),Y Load Accum via stack vector indexed by Y 

STA (d,SP),Y and Store 

SIX ABS,Y Store X Absolute, Y 

STY ABS,X Store Y Absolute, X 

STZ ZP Store Z register (formerly store zero) 
ST2 ABS 
ST2 ZP,X 
ST2 ABS,X 

STA (2P),Z formerly (ZP) 

PHD IMM Push Data Immediate (word) 

PHD ABS Push Data Absolute (word) 

^HZ Push Z register onto stack 

P^2 Pull Z register from stack 

? 

^AZ Transfer Accumulator to Z register 

^2A Transfer Z register to Accumulator 

Transfer Accumulator to Base page register 
Transfer Base page register to Accumulator 



TAB 
TBA 



^SY Transfer Stack Pointer High byte to Y register 

and set "byte" stack-pointer mode 

"^^ Transfer Y register to Stack Pointer High byte 

and set "word" stack-pointer mode 



System Specification for C65 Fred Bowen March 1, 1991 

2.3.7.2 CP0 Operation 

The 4502 has the following 8 user registers: 

A accumulator 

X index-X 

y index-Y 

Z index-Z 

B Base-page 

P Processor stafus ' 

SP Stack pointer 

PC Program counter 



Accumulator 



The accumulator is the only general purpose computational register. 
can be used for arithmetic functions add, subtract, shift, rotate, negate, 
and for Boolean functions and, or, exclusive-or, and bit operations. It 
cannot, however, be used as an index register. 



It 



Index X 



The index register X has the largest number of opcodes pertaining to, 
or using at. It can be incremented, decremented, or compared, but not used 
for arithmetic or logical (Boolean) operations. It differs from other index 
registers m that it is the only register that can be used in indexed-indirect 
^^ (bp,X) operations. It cannot be used in indirect-indexed or (bp) , Y mode 



or 
Index Y 



The index register Y has the same computational constraints as the X 
register, but finds itself in a lot less of the opcodes, making it less 
generally used. But the index Y has one advantage over index X, in that it 
can be us-^ m indirect-indexed operations or (bp) ,Y mode. 

Index Z 

The index register Z is the most unique, in that it is used in the 
smallest number of opcodes. It also has the same computation limitations as 
the X and Y registers, but has an extra feature. Upon reset, the Z register 
IS cleared so that the STZ (store zero) opcodes and non-indexed indirect 
opcodes from previous 65C02 designs are emulated. The 2 -register can also 
be used m indirect-indexed or (bp),2 operations. 

t 

Base page B register 

Early versions of 6502 microprocessors had a special subset of 
instructions that required less code and less time to execute. These were 
referred to as the "zero page" instructions. Since the addressing page 
was always known, and known to be zero, addresses could be specified as 
a single byte, instead of two bytes. 

The CSG4502 also implements this same "zero page" set of instructions 
but goes one step further by allowing the programmer to specify which page 
IS to be the "zero page". Now that the programmer can program this page, it 
IS now, not necessarily page zero, but instead, the "selected page". The term 
"base page" is used, however. 

The B register selects which page will be the "base page", and the user 
sets It by transferring the contents of the accumulator to it. At reset, the 
B register is cleared, giving initially a true "zero page". 



Processor status P register 

_ The processor status register is an 8-bit register which is used to 
indxcate the status of the microprocessor. It contains 8 processor "flags" 
Some of the flags are set or reset based on the results of various types 
of operations. Others are more specific. The flags are... 

Flag Name Typical indication 

K Negative result of operation is negative 

V Overflow result of add or subtract causes signed overflow 

E Extend disables stack pointer extension 

B Break interrupt was caused by BRK opcode 

D Decimal perform add/subtract using BCD math 

1 Interrupt disable IRQ interrupts 

2 2ero result of operation is zero 
C Carry operation caused a carry 

Stack Pointer SP 

The stack pointer is a 16 bit register that has two modes. It can be 
programmed to be either an 8-bit page "programmable pointer, or a full 16-bit 
pointer. The processor status E bit selects which mode will be used. When 
set, the E bit selects the 8-bit mode. When reset, the E bit selects the 
16-bit mode. 

Upon reset, the CSG 4502 will come up in the 8-bit page-programmable 
??^?' ''^^ ^^® stack page set to 1. This makes it compatible with earlier 
bbU^ products. The programmer can quickly change the default stack page bv 
loading the Y register with the desired page and transferring its contents 
to the stack pointer high byte, using the TYS .opcode. The 8-bit stack pointer 
can be set by loading the X register with the desired value, and transferring 
Its contents to the stack pointer low byte, using the TXS opcode. 

J° select the 16-bit stack pointer mode, the user must execute a CLE 
(for CLear Extend disable) opcode. Setting the 16-bit pointer is done by 
loading the X and Y registers with the desired stack pointer low and high 
bytes, respectively, and then transferring their contents to the stack 

P°i:"^|J^^?^"^ 5^^^"5,^P' To return to 8-bit page mode, simple execute a 
SEE (SEt Extend disable) opcode. 

***************************** i,**i,i,i,i,i,i,i,i,^^i,^i,^^,^^^^^^^^^^^^^ 



WARNING 



•* 



If you are using Non-Maskable-Interrupts, or Interrupt * 

Request is enabled, and you want to change BOTH stack * 

pointer bytes, do not put any code between the TXS# and * 

TYS opcodes . Taking this precaution will prevent any * 

interrupts from occuring between the setting of the two * 

stack pointer bytes, causing a potential for writing * 

stack data to an unwanted area* * 

************************* ***:*-k-k**l,*i,i,i,ici,i,i,ii±i,ici,itit****-k-k***** 



Program Counter PC 



The program counter is a 16-bit up-only counter that determines what 
area of memory that program information will be fetched from. The user 
generally only modifies it using jumps, branches, subroutine calls, or 
returns. It is set initially, and by interrupts, from vectors at memory 
addresses FFFA through FFFF (hex) . See "Interrupts" below. 

2.3.7.3 65CE02 Interrupts 

PPQ* ?SS*^ 55?/°'"'' ^^^^^''^^"^^''''''P^ sources on the CSG 4502. These are 
R£S , IRQ*, NMI*, and SO, for Reset, Interrupt Request, Non-Maskable 



Interrupt, and Set Overflow. The Reset is a hard non-recoverable interrupt 
that stops everything. The IRQ is a "maskable" interrupt, in that its 
occurance can be prevented. The NMI is "non-maskable", and if such an 
event occurs, cannot be prevented. The SO, or Set Overflow, is not really 
an interrupt, but causes an externally generated condition, which can be 
used for control of program flow. 

One important design feature, which must be remembered is that no 
interrupt can occur immediately after a one-cycle opcode. This is very 
important, because there are times when you want to temporarily prevent 
interrupts from occurring. The best example of this is, when setting a 
16-bit stack pointer, you do not want an interrupt to occur between the 
times you set the low-order byte, and the high-order byte. If it could 
happen, the interrupt would do stack writes using a pointer that was only 
partially set, thus, writing to an unwanted area. 

IRQ* 

The IRQ* (Interrupt ReQuest) input will cause an interrupt, if it is 
at a low logic level, and the I processor status flag is reset. The interrupt 
sequence will begin with the first SYNC after a multiple-cycle opcode. The two 
program counter bytes PCH and PCL, and the processor status register P, are 
pushed onto the stack. (This causes the stack pointer SP to be decremented 
by 3.) Then the program counter bytes PCL and PCfl are loaded from memory 
addresses FFFE and FFFF, respectively. 

An interrupt caused by the IRQ* input, is similar to the BRK opcode, 
but differs, as follows. The program counter value stored on the stack points 
to the opcode that would have been executed, had the interrupt not occurred. 
On return from interrupt, the processor will return to that opcode. Also, when 
the P register is pushed onto the stack, the B -or "break" flag pushed, is zero, 
to indicate that the interrupt was not software generated. 

NMI* 

The NMI* (Non-Maskable Interrupt) input will cause an interrupt after 
receiving p. high to low transition The interrupt sequence will begin with the 
first SYNC after a multiple-cycle opcode. NMI* inputs cannot be masked by 
the processor status register I flag. The two program counter bytes PCH and 
PCL, and the processor status register P, are pushed onto -the stack. (This 
causes the stack pointer SP to be decremented by 3,) Then the program counter 
bytes PCL and PCH are loaded from memory addresses FFFA and FFFB. 

As with IRQ*, when the P register is pushed onto the stack, the B or 
"break" flag pushed, is zero, to indicate that the interrupt was not software 
generated, 

RES* 

The RES* (reset) input will cause a hard reset instantly as it is 
brought to a low logic level. This effects the following conditions. The 
currently executing opcode will be terminated. The B and Z registers will 
be cleared. The stack pointer will be set to "byte" mode, with the stack 
page set to page 1. The processor status bits E and I will be set. 

The RES* input should be held low for at least 2 clock cycles. But 
once brought high, the reset sequence begins on the CPU cycle. The first 
four cycles of the. reset sequence do nothing. Then the program counter 
bytes PCL and PCH are loaded from memory addresses FFFC and FFFD, and 
normal program execution begins. 

SO 

The SO (set overflow) input does, as its name implies, set the 
overflow or V processor status flag. The effect is immediate as this active 
low signal is brought or held at a low logic level. Care should be taken 



if this signal is used, as some of the opcodes can set or reset the 
overflow flag, as well. NOTE: The SO pin has been removed for C65. 



2.3.7.4 • 65CE02 Addressing Modes 

It should be noted that all 8-bit addresses are referred to as "byte" 
addresses, and all 16-bit addresses are referred to as "word" addresses. In 
all word addresses, the low-order byte of the address is fetched from the lower 
of two consecutive memory addresses, and the high-order byte .of" the address 
is fetched the higher of the two. So, in all operations, the low-order address 
is fetched first. 

Implied OPR 

The register or flag affected is identified entirely by the opcode 
in this (usually) single cycle instruction. In this document, any implied 
operation, where the implied register is not explicitly declared, implies 
the accumulator. Example: INC with no arguments implies "increment the 
accumulator". 

Immediate (byte, word) OPR #xx 

The data used in the operation is taken from the byte or bytes 
immediately following the opcode in the 2-byte or 3-byte instruction. 

Base Page OPR bp (formerly Zero Page) 

The second byte of the two-byte instruction contains the low-order 
address byte, and the B register contains the high-order address byte of 
the memory location to be used by the operation. 

Base Page, indexed by X OPR bp,X (formerly Zero Page^X) 

The second byte of the two-byte instruction is added to the X index 
register to form the low-order address byte, and the B register contains the 
high-order address byte of the memory location to be used by the operation. 

Base Page, indexed by Y OPR bp,Y (formerly Zero Page,Y) 

The second byte of the two-byte instruction is added to the Y index 
register to form the low-order address byte, and the B register contains the 
high-order address byte of the memory location to be used by the operation. 

Absolute OPR abs 

The second and third bytes of the three-byte instruction contain the 
low-order and high-order address bytes, respectively, of the memory location 
to be used by the operation. 

Absolute, indexed by X OPR abs,X 

The second and third bytes of the three-byte instruction are added to 
the unsigned contents of the X index register to form the low-order and 
high-order address bytes, respectively, of the memory location to be used 
by the operation. 

Absolute, indexed by Y OPR abs,Y 

The second and third bytes of the three-byte instruction are added to 
the unsigned contents of the Y index register to form the low-order and 
high-order address bytes, respectively, of the memory location to be used ■ 



by the operation. 

Indirect (word) OPR (aJos) {JMP and JSR only) 

The second and third bytes of the three-byte instruction contain the 
low-order and high-order address bytes, respectively, of two memory locations 
containing the low-order and high-order JMP or JSR addresses, respectively. 

Indexed by X, indirect (byte) OPR (bp,X) (formerly (zp,X) ) 

The second byte of the two-byte instruction is added to the contents 
of the X register to form the low-order address byte, and the contents of the B 
register contains the high-order address byte, of two memory locations that 
contain the low-order and high-order address of the memory location to be used 
by the operation. 

Indexed by X, indirect (word) . OPR (abs,X) (JMP and JSR only) 

The second and third bytes of the three-byte instruction. are added to 
the unsigned contents of the X index register to form the low-order and 
high-order address bytes, respectively, of two memory locations containing the 
low-order and high-order JMP or JSR address bytes: 

Indirect, indexed by Y OPR (bp) , Y (formerly (2p),Y ) 

The second byte of the two-byte instruction contains the low-order byte, 
and the B register contains the high-order address byte of two memory loc- 
ations whose contents are added to the unsigned Y index register to form the 
address of the memory location to be used by the operation. 

Indirect, indexed by Z OPR (bp) , Z . (formerly (zp) ) 

The second byte of the two-byte instruction contains the low-order byte, 
and the B register contains the high-order address byte of two memory loc- 
ations whose contents are added to the unsigned Z index register to form the 
address of the memory location to be used by the operation. 



Stack Pointer Indirect, indexed by Y OPR (d,SP),Y 



(new) 



The second byte of the two-byte instruction contains an unsigned offset 
value, d, which is added to the stack pointer (word) to form the address of 
two memory locations whose contents are added to the unsigned Y register to 
;form the address of the memory location to be used by the operation. 

Relative (byte) Bxx LABEL (branches only) 

The second byte of the two-byte branch instruction is siign- extended to 
a full word and added to the program counter (now containing the opcode address 
plus two) . If the condition of the branch is true, the sum is stored back into 
the program counter. 

Relative (word) Bxx LABEL (branches only) 

The second and third bytes of the three-byte branch instruction are 
added to the low-order and high-order program counter bytes, respectively, 
(the program counter now contains the opcode address plus two) . If the ' * 
condition of the branch is true, the sum is stored back into the program 
counter. 



System Specification for C65 Fred Bowen 

2.3.7.5 65CE02 Instmction Set 



March 1, 1991 



Add memory to accuBnilator with carry 

A=A+M+C 



ADC 



Abbre V , 



Opcode 



IMM 


69 


BP 


€5 


BP,X 


75 


ABS 


6D 


ABS,X 


7D 


ABS,Y 


79 


(BP,X) 


61 


(BP),y 


71 


(BP),Z 


72 



Addressing Mode 

immediate 

base page 

base page indexed X 

absolute 

absolute indexed X 

absolute indexed Y 

base page indexed indirect X 

base page indirect indexed. Y 

base page indirect indexed Z 

Bytes Cycles Mode 

2 2 immediate 

2 3 base page non-indexed, or indexed X or Y 

3 4 absolute non-indexed, or indexed X or Y 

2 5 base page indexed indirect X, or indirect indexed Y or Z 

The ADC instructions add data fetched from memory and carry to the 
contents of the accumulator. The results of the add are then stored in the 
accumulator. If the "D" or Decimal Mode flag, in the processor status regis- 
ter, then a Binary Coded Decimal (BCD) add is performed. 

The "N" or Negative flag will be set if the sum is negative, otherwise 
it xs cleared. The "V" or Overflow fl^ will be set if the sign of the sum 
is different from the sign of both addends, indicating a signed overflow. 
Otherwise, it is cleared. The "Z" or Zero flag is set if the sum (stored into 
the accumulator) is zero, otherwise, it is cleared. The "C" or carry is set 
if the sum of the unsigned addends exceeds 255 (binary mode) or 99 (decimal 
mode) . 

Flags 
NVEBDIZC 
NV ZC 



System Specification for C65 Fred Bowen March 1, 1991 

And memory logically with accumulator AKD 

A=A.and.M 

Addressing Mode 

immediate 

base page 

base page indexed X 

absolute 

absolute indexed X 

absolute indexed Y 

base page indexed indirect 

base page indirect indexed 

base page indirect indexed 

Bytes Cycles Mode 
2 2 immediate 

2 _ 3 base page non-indexed, or indexed X or Y 

3 4 absolute non-indexed, or indexed X or Y 

2 5 base page indexed indirect X, or indirect indexed Y or Z 

The AND instructions perform a logical *'and" between data bits fetched 
from memory and the accumulator bits. The results are then stored in the 
accumulator. For each acctamulator and corresponding memory bit that are both 
logical I's, the result is a 1. Otherwise it is 0. 

The "N" or Negative flag will be set if the bit 7 result is a 1, 
Otherwise it is cleared. The "Z" or Zero flag is set if all result bits are 
zero, otherwise, it is cleared. 

Fl-igs 
NVEBDIZC 
N Z- 



Abbrev. 


Ope 


IMM 


29 


BP 


25 


BP,X 


35 


A6S 


2D 


ABSfX 


3D 


ABS,Y 


39 


X (BP,X) 


21 


Y (BP),Y 


31 


2 (BP),Z 


32 



System Specification for C65 



Fred Bo wen 



March 1, 1991 



Arithmetic shifts, memory or accuanilator, left ox xight 



ASL ASR ASH 



ASL Arithmetic shift left A or M 
ASR Arithmetic shift right A or M 
ASW Arithmetic shift left M (word) 



Addressing Mode 

register (A) 

base page 

base page indexed X 

absolute 

absolute indexed X 



Abbrev, 





OA 


43 


BP 


06 


44 


BP,X 


16 


54 


ABS 


OE 




ABS,X 


IE 





A<A«1 or M<M«1 
A<A»1 or M<M»1 

Mx<Mw«l 

Opcodes ■ 
ASL ASR ASW 



CB 



Bytes Cycles Mode 

1 1 register (ASL) 

1 2 register (ASR) 

2 4 base page (byte) non-indexed, or indexed X 

3 5 absolute non-indexed, or indexed X 
3 7 absolute (ASW) 

The ASL instructions shift a single byte of data in memory or the ac- 
cumulator left (towards the most significant bit) one bit position. A is 
shifted into bit 0. 

The "N" or Negative bit will be set if the result bit 1 is (operand bit 
6 was) a 1. Otherwise, it is cleared. The "Z" or Zero flag is set if ALL 
result bits are zero. The "C" or Carr^ f lag is set if the bit shifted out is 
(operand bit 7 was) a 1. Otherwise, it is cleared. 

The ASR instructions shift a single byte of data in memory or the ac- 
cumulator right (towards the least significant bit) one bit position. Since 
this is an arithmetic shift, the sign of the operand will be maintained. 

The "N" or Negative bit will be set if bit 7 (operand and result) a 1. 

Otherwise, it is cleared. The "2"* or Zero flag is set if ALL result bits are 

zero. The "C" or Carry flag is set if the bit shifted out is (operand bit 
was) a 1. Otherwise, it is cleared. 

The ASW instruction shifts a word (two bytes) of data iH memory left 
(towards the most significant bit) one bit position. A zero is shifted into 
bit 0. 

The "N" or Negative bit will be set if the result bit 15 is (operand bit 
14 was) a 1. Otherwise, it is cleared. The "Z" or Zero flag is set if ALL 
result bits (both bytes) are zero. The "C" or Carry flag is set if the bit 
shifted out is (operand bit 15 was) a 1. Otherwise, it is cleared. 

Flags 
NVEBDIZC 
N 2C 



System Specification for C65 
Branch conditional or unconditional 



Fred Bowen March 1, 1991 

BCC BCS BEQ BMI BNE 
BPL BRA BVC BVS 



Opcode Opcode Byte Opcode Word Opcode 
Title Relative Relative Purpose 



BCC 


90 


BCS 


BO 


BEQ 


FO 


BMI 


30 


BNE 


DO 


BPL 


10 


BRA 


80 


BVC 


50 


BVS 


70 


Bytes 


Cycles 


2 


2 


3 


3 



if Carry Clear 

if Carry Set 

if EQual (2 flag set) 

if Minus (N flag set) 

if Not Equal (2 flag clear) 

if PLUS (N flag clear) 

Always 

if overflow Clear 

if overflow Set 



93 Branch 

B3 Branch 

F3 Branch 

33 Branch 

D3 Branch 

13 Branch 

83 BRanch 

53 Branch 

73 Branch 

Mode 
byte- relative 
word-relative 

All branches of this type are taken, if the condition indicated by 
-he opcode is true. All branch relative offsets are referenced to the 
branch opcode location+2. This means that fox byte-relative, the offset is 
relative to the location after the two instruction bytes. For word-relative, 
the offset is relative to the last of the three instruction bytes - 



Flags 

N V E B D I 



Z C 



Break (force an interrupt) 



BRK 



Bytes 
2 



Cycles 
7 



Mode 
implied 



Opcode 
00 



(stack) <PC+lw,P SP<SP-2 



The BRK instruction causes the processor to enter the IRQ or Interrupt 
ReQuest state. The program counter (now incremented by 2), bytes PCH and PCL, 
and the processor status register P, are pushed onto the stack. (This causes 
the stack pointer SP to be decremented by 3.) Then the program, counter bytes 
PCL and PCH are loaded from memory addresses FFFE and FFFF, respectively. 

The BRK differs from an externally generated interrupt request (IRQ) as 
follows. The program counter value stored on the stack is PC+2, or the address 
of the BRK opcode+2. On return from interrupt, the processor will return to 
the BRK address+2, thus skipping the opcode byte, and a following "dummy" byte, 
A normal IRQ will not add 2, so that a return will execute the interrupted 
opcode. Also, when the P register is pushed onto the stack, the B or "break" 
flag is set, to indicate that the interrupt was software generated* All outside 
interrupts push P with the B flag cleared. 

Flags 
NVEBDIZC 



System Specification for C65 Fred Bowen March 1, I99i 



Branch to subroutine 

BSR 

Bytes Cycles Mode Opcode 

3 5 word-relative 63 (stack) <PC+2w SP<SP-2^ 

r^r...^^ ^^^ ?^^ S^S"'^^.^® SuhRontine instruction pushes the two proarain 

sianerof?s^? fn\^"^ ^^^ °"^° ^^^ ^^^^^- ^^ ^^^" ^<^ds the word-rlfSive 
signed offset to the program counter. The relative offset is referenced 

bvte nf^fhr^h °^ K^: ^1? opcode+2, hence, it is relative to ?he thirS 
byte of the three-byte BSR instruction. The return address on thS^?^^v 
|^|%P°^!?^= t? this address. This was done to make it compatible wi?hth4 
RTS functionalxty, and to be consistant will other worS-?SlatIvS operations 

Flags 
NVEBDIZC 



Clear processor status bits 



CLC Clear the Carry bit 

CLD Clear the Decimal mode bit 

CLE Clear stack Extend disable bit 

CLI Clear Interrupt disable bit 

CLV ^ear the Oveflow bit 

Bytes Mode 
1 implied 



CLC CLD CLE CLI CLV 



)code 
18 


Cycles 

1 


Flags 
NVEBDIZC 


D8 
02 
58 
BB 


1 
2 
2 

1 





The purpose of Ltending the CLI tl^2 c^clel is K^S^if^'^^^^^ '=^''^^^- 
occur immedia-hpi'</ if «„« ■ ^^-^ ,^° ^ cycxes, is to enable an interrupt to 

cycle iS^l^ctlon;.'^ °"^ " pending. Interrupts cannot occur after single 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Compare registers with memory 



CMP CPX CPY CPZ 



CMP Compare accumulator with memory (A-M) 

CPX Compare index X with memory (X-M) 

CPY Compare index Y with memory (Y-M) 

CPZ Compare index Z with memory (Z-M) 



Addressing Mode 

immediate 

base page 

base page indexed X 

absolute 

absolute indexed X 

absolute indexed Y 

base page indexed indirect 

base page indirect indexed 

base page indirect indexed 









Opcodes' 






Abbrev. 


CMP 


CPX 


CPY 


CPZ 




IMM 


C9 


EO 


CO 


C2 




BP 


C5 


£4 


C4 


D4 




BP,X 


D5 










ABS 


CD 


EC 


CC 


DC 




ABS,X 


DD 










ABS,Y . 


D9 








X 


(BP,X) 


CI 








Y 


(BP),y 


Dl 








Z 


(BP),Z 


D2 









Bytes 
2 
2 
3 
2 



Cycles 

2 
3 
4 

5 



Mode 
immediate 

base page non-indexed, or indexed X or Y 
absolute non-indexed, or indexed X or Y 
base page indexed indirect X, or indirect indexed Y or Z 



Compares are performed by subtracting a value in memory from the 
register being tested. The results are not stored in any register^ except 
the following status flags are updated. 

The "N" or Negative flag will be set if the result is negative (assuming 
signed operands) , otherwise it is cleared. The "Z" or Zero flag is set if the 
result is zero, otherwise it is cleared. The "C" or carry flag is set if the 
unsigned register value is greater than or equal to the unsigned memory value. 

Flags 
NVEBDIZC 
N ZC 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Compare registers with memory 



CMP CPX CPY CPZ 



C>3P Compare acciamulator with memory (A-M) 

CPX Compare index X with memory (X-M) 

CPY Compare index Y with memory (Y-M) 

CPZ Compare index Z with memory (Z-M) 









Opcodes 






Abbrev. 


CMP 


CPX 


CPY 


CPZ 




IbaM 


C9 


EO 


CO 


C2 




BP 


C5 


£4 


C4 


D4 




BP,X 


D5 










ABS 


CD 


EC 


CC 


DC 




ABS,X 


DD 










ABS,Y . 


D9 








X 


(BP,X) 


CI 








Y 


(BP),Y 


Dl 








Z 


(BP),Z 


D2 









Addressing Mode 

immediate 
base page 

base page indexed X 
absolute 
j absolute indexed X 
absolute indexed Y 
base page indexed indirect 
base page indirect indexed 
base page indirect indexed 

Bytes Cycles Mode 

2 2 immediate 

2 3 base page non-indexed, or indexed X or Y 

3 4 absolute non-indexed, or indexed X or Y 

2 5 base page indexed indirect X, or indirect indexed Y or Z 

Compares are performed by subtracting a value in memory from the 
register being tested. The results are not stored in any register, except 
the following status flags are updated. 

The "N" or Negative flag will be set if the result is negative {assuming 
signed operands) , otherwise it is cleared. The "Z" or Zero flag is set if the 
result is zero, otherwise it is cleared. The "C" or carry flag is set if the 
unsigned register value is greater than or equal to the unsigned memory value. 

Flags 
NVEBDIZC 
N ZC 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Exclusive OR accumulator logically with memory 



EOR 



A=A.or.M.and. .not. (A.and.M) 
Addressing Mode 

iininediate 

base page 

base page indexed X 

absolute 

absolute indexed X 

absolute indexed Y 

base page indexed indirect 

base page indirect indexed 

base page indirect indexed 



Abbre V , 



Opcode 





IMM 


.49 




BP 


45 




BP,X 


55 




ABS 


4D 




ABS,X 


5D 




ABS,Y 


59 


X 


{BP,X) 


41 


Y 


(BP),y 


51 


Z 


(BP),Z 


52 



Bytes 
2 
2 
3 
2 



Cycles 
2 
3 

4 
5 



Mode 
immediate 

base page non-indexed, or indexed X or Y 
absolute non-indexed, or indexed X or Y 
base page indexed indirect X, or indirect indexed Y or 2 



The EOR instructions perform an "exclusive or" between bits fetched 
from memory and the accumulator bits. The results are then stored in the 
accumulator. Fox each accumulator or corresponding memory bit that are 
different (one 1, and one 0) the result is a 1. Otherwise it is 0. 

The "N" or Negative flag will be set if the bit 7 result is a 1 
Otherwise It is cleared. The "Z" or Zero flag is set if all result bits are 
zero, otherwise, it is cleared. > 

Flags 
NVEBDIZC 
N Z- 



i 



System Specification for C65 
Jun^ to siabroutine 



Fred Bowen 



March 1, 1991 
JSR 



Addressing Mode 

absolute 

absolute indirect 

absolute indexed indirect X 



Abbrev. Opcode bytes cycles 



A£S 
(ABS) 
(ABS,X) 



20 3 

22 3 

23 3 



The JSR Jump to SubRoutine instruction pushes the two program counter 
bytes PCH and PCL onto the stack. It then loads the program counter with the 
new address. The return address, stored on the stack, is actually the address 
of the JSR opcode+2, ox is pointing to the third byte of the three-byte JSR 
instruction. 

Flags 
NVEBDIZC 



Load registers 



U3A LDX LDY LDZ 



LDA 
LDX 
LDY 
LDZ 



Load Accumulator from memory 
Load index X from memory 
Load index Y from memory 
Load index Z from memory 



A<M 
X<M 

Y<M 
Z<M 



Addressing Mode Abbrev, 

immediate IMM ' 

base page BP 

base page indexed X BP,X 

base page indexed Y BP,Y 

absolute ABS 

absolute indexed X ABS,X 

absolute indexed Y ABS,Y 

base page indexed indirect X (BP,X) 

base page indirect indexed Y <BP),Y 

base page indirect indexed Z <BP),Z 

stack vector indir indexed Y <d, SP),Y 



LDA LDX LDY LDZ 



A9 
A5 
35 

AD 
BD 
B9 
Al 
Bl 
B2 
E2 



A2 

A6 

B6 
AE 

BE 



AO 
A4 
B4 

AC 
BC 



A3 



AB 
BB 



Bytes Cycles Mode 

2 2 immediate 

2 3 base page non-indexed, or indexed X or Y 

3 4 absolute non-indexed, or indexed X or Y 

2 5 base page indexed indirect X, or indirect indexed Y or Z 

2 6 stack vector indirect indexed Y 

These instructions load the specified register from memory. The "N" 
or Negative flag will be set if the bit 7 loaded is a 1. Otherwise it is 
cleared. The "Z" or Zero flag is set if all bits loaded are zero, otherwise, 
it is cleared. 

Flags 

NVEBDIZC 
7 2_ 



System Specification for C65 Fred Bowen March 1, 1991 

Negate (twos complement) accumalatox I^q 

Addressing Mode Opcode Bytes Cycles 
implied 42 1 2 

nf th^^rfL^*^ or "negate" instruction performs a two's -complement inversion 
?L^cLf^^ ^J the accumulator. For example, 1 becomes -l/-5 becomes sf etc 
The same can be achieved by subtracting A from zero. 

^ 1 Jk^ "^^ or Negative flag will be set if the accumulator bit 7 becomes 
L'iand'S^rriero/' '='"^""'* "^^ ^^" °^ "^^° '''^ '' -^ '' ^^- accu^S?a?L 

Flags 
NVEBDIZC 
N- -Z- 



No- operation 

Addressing Mode Opfiode Bytes Cycles 
implied EA 1 i'> 



NOP 



. MLD ^^^ !J°^ no-operation instruction has no effect, unless used following 
^S^zSSf^ ^" ^^^ ^^ interpreted as a EOM end-of-map instruction! ^ 



(See EOM) 

Flags 
NVEBDIZC 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Or memoxy logically with accumulator 



ORA 



A-A.or.M 



Addressing Mode 

immediate 

base page 

base page indexed X 

absolute 

absolute indexed X 

absolute indexed Y 

base page indexed indirect 

base page indirect indexed 

base page indirect indexed 



Abbre V , 



Opcode 



IMM 


09 


BP 


05 


BP,X 


15 


ABS 


OD 


ABS,X 


ID 


ABS,Y 


19 


X (BP,X) 


01 


Y (BP),Y. 


11 


Z CBP),2 


12 



Bytes 
2 
2 
3 
2 



Cycles 
1 
3 
4 
5 



Mode 

immediate 

base page non-indexed, or indexed X or Y 

absolute non-indexed, or indexed X or Y 

base page indexed indirect X, or indirect indexed Y or 2 



The ORA instructions perform a logical "or" between data bits fetched 
from memory and the accumulator bits. The results are then stored in the 
accumulator. For either accumulator or corresponding memory bit that is a 
logical I's, the result is a 1. Otherwise it is 0. 

The "N" or Negative flag will be set if the bit 7 result is a 1 . 
Otherwise it is cleared. The "2" or Zero flag is set if all result bits are 
zero, otherwise, it is cleared. 

Fl-jgs 
NVEBDIZC 
K 2- 



System Specification for C65 



Ptill register data from stack 



Fred Bowen 



March 1, 1991 



PIA PI^P PLX PLY PLZ 



FLA 
PLX 
PLY 
PLZ 

PLP 

Bytes 
1 



Opcode 

Pull Accumulator from stack 68 

Pull index X from stack FA 

Pull index Y from stack 7A 

Pull index Z from stack FB 

Pull Processor status from stack 28 



Cycles 
3 



Mode 

register 



I - J ^^^ Pull register operations, first, increment the stack pointer SP, 
■and then, load the specified register with data from the stack. 

Except in the case of- PLP, the "N" or Negative flag will be set if the 
bit 7 loaded is a 1 . Otherwise it is cleared. The "Z" or Zero flag is set if 
all bits loaded are zero, otherwise, it is cleared. 

In the case of PLP, all processor flags (P register bits) will be loaded 
from the stack, except the "B" or "break" flag, which is always a 1, and the 
"E" or "stack pointer Extend disable" flag, which can only be set by SEE, or 
cleared by CLE instructions. 



Flags 
NVEBDIZC 
N Z- 

76--3210 



(except PLP) 
(PLP only) 



System Specification for C65 Fred Bowen March 1, 1991 

Push registers or data onto stack PHA PHP PHH PHX PHY PHZ 

PHA Push Accumulator onto stack 

PHP Push Processor status onto stack 

PHW Push a word from memory onto stack 

PHX Push index X onto stack 

PHY Push index Y onto stack 

PHZ Push index Z onto stack 

Opcodes 
Addressing Mode Abbrev. PHA PHP PHW PHX PHY PHZ 

register 48 08 DA 5A ■ DB 

word immediate IMMw F4 

word absolute ABSw FC 

Bytes Cycles Mode 

1 3 register 

3 5 word immediate 

3 7 word absolute 

These instructions push either the contents of a register onto the 
stack, or push two bytes of data from memory (PHW) onto the stack. If a 
register is pushed, the stack pointer will decrement a single address. If 
a word from memory is pushed C [SP3<-PC(L0) , [SP-13<-PC(HI) ) , the stack pointer 
will decrement by 2. No flags are changed. 

Flags 
NVEBDIZC 



Reset memory bits RMB 

M=M.and.-bit 

Opcode to reset bit 






12 3 4 5 6 


7 


07 


17 27 37 47 57 67 


77 


Bytes 
2 


Cycles Mode 
4 base-page 





These instructions reset a single bit in base-page memory, as specified 
by the opcode. No flags are modified. 

Flags 
NVEBDIZC 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Rotate memory or accumulator, left or right 



ROI. ROR ROW 



ROL Rotate memory or accumulator left throught carry 
ROR Rotate memory or accumulator right throught carry 
ROW Rotate memory (word) left throught carry 



Addressing Mode 

register (A) 

base page 

base page indexed X 

absolute 

absolute indexed X 





Opcodes 


Abbrev . 


ROL 


ROR 




2A 


6A 


BP 


26 


66 


BP,X 


36 


76 


ABS 


2E 


6£ 


ABS,X 


3E 


7E 



ROW 



EB 



Bytes Cycles Mode 

1 1 register 

2 4 base page (byte) non-indexed, or indexed X 

3 5 absolute non-indexed, or indexed X 
2 6 absolute (word) 

The ROL instructions shift a single byte of data in memory or the ac- 
cumulator left (towards the most significant bit) one bit position. The state 
of the "C" or "carry" flag is shifted into bit 0. 

The "N" or Negative bit will be set if the result bit 7 is (operand bit 
6 was) a 1. Otherwise, it is cleared. The "2" or Zero flag is set if ALL ■ 
result bits are zero. The "C" or Carry flag is set if the bit shifted out is 
(operand bit 7 was) a 1. Otherwise, it is cleared. 

> 

The ROR instructions shift a single byte of data in memory or the ac- 
cumulator right (towards the least significant bit) one bit position. The 
state of the "C" or "carry" flag is shifted into bit 7. 

The "N" or Negative bit will be set if bit 7 is (carry was) a 1. 

Otherwise, it is cleared. The "Z" or Zero flag is set if ALL result bits are 

zero. The "C" or Carry flag is set if the bit shifted out is (operand bit 
'was) a 1. Otherwise, it is cleared. 

The ROW instruction shifts a word (two bytes) of data in memory left 
(towards the most significant bit) one bit position. The statedf the "C" or 
'carry" flag is shifted into bit 0. 

The "N" or Negative bit will be set if the result bit 15 is (operand bit 
14 was) a 1. Otherwise, it is cleared. The "2" or Zero flag is set if ALL 
result bits (both bytes) are zero. The "C or Carry flag is set if the bit 
shifted out is (operand bit 15 was) a 1. Otherwise, it is cleared. 

Flags 
NVEBDI2C 
N ZC 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Return from BHK, interrupt, kemal, or sixbroutine 



RTI RTN RTS 



Operation 



description 



Opcode bytes cycles 



RTI Return from interrupt 
RTN #n Return from kernal 
RTS Return from subroutine 



40 
62 
60 



P,PCw<(SP),SP<SP+3 
PCw< (SP) +1, SP<SP+2+N 
PCw< (SP) +1, SP<SP+2 



The RTI or ReTurn from Interrupt instruction pulls P register data 
and a return address into program counter bytes PCI and PCH from the stack. 
The stack pointer SP is resultantly incremented by 3. Execution continues 
at the address recovered from the stack. 

Flags 
NVEBDIZC 
76 3210 (RTI only) 

The RTS or ReTurn from Subroutine instruction pulls a return address 
into program counter bytes PCL and PCH from the stack. The Stack pointer SP 
is resultantly incremented by 2. Execution continues at the address recovered 
+ 1, since BSR and JSR instructions set the return address one byte short of 
the desire return address. 

The RTN or ReTurn from kerNal subroutine is similar to RTS, except that 
it contains an immediate parameter N indicating how many extra bytes to discard 
from the stack. This is useful for returning from subroutines which have 
arguments passed to them on the stack. The stack pointer SP is incremented by 
2 + N, instead of by 2, as in RTS. 

Flags 
NVEBDIZC 

__ ^_ (RTN and RTS) 

76 3210 (RTI) 



System Specification for C65 




Fred B 


Set memory bits 




• 


M*=M.or.bit 






Opcode to set bit 
12 3 4 5 6 


7 




87 97 A7 B7 C7 D7 E7 


F7 




Bytes Cycles . Mode 
2 4 base-page 







March 1, 1991 



SMB 



These instructions set a single bit in base-page memory, as specified 
by the opcode. No flags are modified. 

Flags 
NVEBDI2C 



Store registers 



STA Store Accumulator to memory M<A 

STX Store index X to memory M<X 

STY Store index Y to memory M<Y 

ST2 Store index Z to memory M<Z 



Addressing Mode 

> 
base page 

base page indexed X 
base page indexed Y 
absolute 

absolute indexed X 
absolute indexed Y 
base page indexed indirect 
base page indirect indexed 
base page indirect indexed 
stack vector indir indexed 



Abbre V . 

BP 

BP,X 

BP,Y ■ 

ABS 

ABS,X 

ABS,Y 

(BP,X) 

(BP),Y 

(BP),2 

(d,SP},Y 



85 
95 

8D 
9D 
99 
81 
91 
92 
82 



STA STX STY STZ 



Opcodes 
STA STX STY STZ 



86 

96 
8E 

9B 



84 
94 

BC 
SB 



64 
74 

9C 
9E 



Bytes 
2 
3 
2 
2 



Cycles 
3 
4 
5 

6 



Mode 
base page non-indexed, or indexed X or Y 
absolute non-indexed, or indexed X or Y 
base page indexed indirect X, or indirect indexed Y or 2 
stack vector indirect indexed Y 



These instructions store the specified register to memory- No 
are affected. 

Flags ■ 
NVEBDI2C 



flags 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Transfers (between registers) TAB TAX TAX TAZ 

TEA TSX TSY TXA 
TXS TYA TYS TZA 

Operation Flags Transfer 

Symbol Code NVEBDI2C from to . 

^^ *? acc\anulator base page reg 

l^ ^ N 2- accumulator index X reg 

TB7 V"-B N-----Z- accumulator index Y reg 

TQi nZ ^~ accumulator index Z reg 

iov Z? J! ^" ^^®® P^5® ^®9 accumulator 

l%y 7^ « ^ ~ ®^^*^^ P^"" ^°" ^"^«^ ^ ^eg 

IZl o ^ " ^^^'^^ P^^ ^^9h index Y reg 

?vS Q^ ^ ^" i^<^ex X reg accumulator 

?va QQ Tt ^^"^^^ ^ ^®5 stack ptr low 

TVQ ?l ^ " index Y reg accumulator 

T7^ ^? « ^"^^^ ^ ^^5 stack ptr high 

^^■^ feB N z- index Z reg accumulator 

4-n ■h>,«^^S®^i^^^'^^^i°''^ transfer the contents of the specified source register 
to the specified destination register. Any transfer to A, X, Y, or Z will 
affect the flags as follows. The "N" or "negative" flag will be set if the 
value ^moved is negative (bit 7 set), otherwise, it is cleared. The "Z" or 

zero flag will be set if the value moved is -zero (all bits 0) , otherwise, it 
IS cleared. Any transfer to SPL or SPH will not alter any flags. 

* WARNING * 

> 

* If you are using Non-Maskable-Interrupts, or Interrupt * 

* Request is enabled, and you want to change BOTH stack * 
pointer bytes, do not put any code between the TXS and * 

* TYS opcodes. Taking this precaution will prevent any * 
interrupts from occuring between the setting of the two * 

* stack pointer bytes, causing a potential for writing * 

* stack data to an unwanted area. * 

Bytes Cycles Mode 

1 1 register * 



System Specification for C65 



Test and reset or set memory bits 



Fred Bowen 



March 1, 1991 



TEB TSB 



TRB Test and reset memory bits with accumulator (M.or.A) ,M<M.and.-A 
TSB Test and set memory bits with accumulator (M.or.A) ,M<M.or.A 



Addressing Mode 

base page 

absolute 



Abbrev . 

BP 
ABS 



Opcodes 
TRB TSB 



14 
IC 



04 
OC 



These instructions test and set or reset bits in memory, using the 
I accumulator for both a test mask, and a set or reset mask. First, a logical 
,AND is performed between memory and the accumulator. The "Z" or "zero" flag 
is set if all bits of the result of the AND are zero. Otherwise it is reset. 

The TSB then performs a logical OR between the bits of the accumulator 
and the bits in memory, storing the result back into memory. 

The TRB, instead, performs a logical AND between the inverted bits of 
the accumulator and the bits in memory, storing the result back into memory. 



Bytes 
2 
3 



Cycles 
4 
5 



Mode 
base page non-indexed 
absolute non-indexed 



Flags 
NVEBDIZC 
-Z- 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.3.7.6 4502 Opcode Table 






12 3 4 5 


6 


7 


8 


9 


A 


B 


C 


D 


E 


r 


BRK 


ORA 
INDX 


clel. 


seeL- 


TSB 
ZP 


ORA 
ZP 


ASL 
ZP 


RMBO 
ZP 


PHP 


ORA 
IMM 


ASL 


tsyI- 


TSB 
ABS 


ORA 

ABS 


ASL 
ABS 


EBRD 
ZP 


BPL 
KEL 


ORA 
INDY 


ORA 
INDZ 


bplI- 

WREL 


TRB 
ZPX 


ORA 
ZPX 


ASL 
ZPX 


RMBl 
ZP 


CLC 


ORA 
ABSY 


INC. 


INzL 


TRB 
ABS 


ORA 
ABSX 


ASL 
ABSX 


BBRl 
ZP 


JSR 
ABS 


AND 
INDX 


jsrL 

IND 


jsrL 

INDX 


BIT 
ZP 


AND 
ZP 


ROL 
ZP 


RMB2 
ZP 


PLP 


AND 
IMM 


ROL 


TYS*- 


BIT 
ABS 


AND 
ABS 


ROL 
ABS 


BBR2 
ZP 


BMI 
REL 


AND 
INDY 


AND 
INDZ 


BMlL 
HREL 


BIT 
ZPX 


AND 
ZPX 


ROL 
ZPX 


RMB3 
ZP 


SEC 


AND 
ABSY 


DEC 


DEzL 


BIT 
ABSX 


AND 
ABSX 


ROL 
ABSX 


BBR3 
ZP 


RTI 


EOR 
INDX 


negL 


asrL 


asrI- 

ZP 


EOR 
ZP 


LSR ■ 
ZP 


BMB4 
ZP 


PHA 


EOR 
IMM 


LSR 


TAzl- 


OMP 
ABS 


EOR 
ABS 


LSR 
ABS 


BBR4 
ZP 


BVC 

REL 


EOR 

INDY 


EOR 
INDZ 


BVcL 
WREL 


asrI- 

ZPX 


EOR 
ZPX 


LSR 
ZPX 


RMB5 
ZP 


CLI 


EOR 
ABSY 


PHY 


tabL 


MApL 


EOR 
ABSX 


LSR 
ABSX 


BBR5 
ZP 


RTS 


ADC 
IKDX 


rtnI- 


bsrI- 

WREL 


STZ 
ZP 


ADC 
ZP 


ROR 
ZP 


RMB6 
2P 


PLA 


ADC 

IMM 


ROR 


tzaL 


JMP 
IND 


ADC 
ABS 


ROR 
ABS 


BBR6 
ZP 


BVS 
REL 


ADC 

INDY 


ADC 
INDZ 


BvsL 

HREL 


STZ 
ZPX 


ADC 
ZPX 


ROR 
ZPX 


RMB7 
ZP 


SEI - 


ADC 
ABSY 


PLY 


tbaL 


JMP 
INDX 


ADC 
ABSX 


ROR 
ABSX 


BBR7 
ZP 


BRO 

REL 


STA 
INDX 


staL 

IDSP 


BRu!- 
WREL 


STY 
ZP 


STA 
ZP 


SIX 

ZP 


SMBO 
ZP 


DEY 


BIT 
IMM 


TXA 


STY i- STY 
ABSX ABS 


STA 
ABS 


STX 
ABS 


BBSO 
ZP 


BCC 
REL 


STA 
INDY 


STA 
INDZ 


BccL 

WREL 


STY 
ZPX 


STA 
ZPX 


STX 
ZPY 


SMBl 
ZP 


TYA 


STA 
ABSY 


TXS 


STxL 

absy 


STZ 
ABS 


STA 
ABSX 


STZ 
ABSX 


BBSl 
ZP 


LDY 
IMM 


LDA 
INDX 


LDX 
IMM 


LDzl" 
IMM 


LDY 
ZP 


LDA 
ZP 


LDX 
ZP 


SMB2 
ZP 


TAY 


LDA 
IMM 


TAX 


LDZ - 
ABS 


LDY 
ABS 


LDA 
ABS 


LDX 
ABS 


BBS2 
ZP 


BCS 
REL 


LDA 
INDY 


LDA 
INDZ 


BcsL 

WREL 


LDY 
ZPX 


LDA 
ZPX 


LDX 
ZPY 


SMB3 
ZP 


CLV 


LDA 
ABSY 


TSX 


LDZ - 
ABSX 


LDY 
ABSX 


LDA 
ABSX 


LDX 
ABSY 


BBSS 
ZP 


CPY 
IMM 


CMP 
INDX 


CPZ - 
IMM 


DEW - 
ZP 


CPY 
ZP 


CMP 
ZP 


DEC 
ZP 


SMB4 
ZP 


INY 


CMP 
IMM 


DEX 


ASWl- 
ABS 


CPY 

ABS 


CMP 
ABS 


DEC 
ABS 


BBS 4 
ZP 


BKE 
REL 


CMP 
INDY 


CMP 
INDZ 


BNE - 
WREL 


cpzL 

ZP 


CMP 
ZPX 


DEC 
ZPX 


SMB5 
ZP 


OLD 


CMP 
ABSY 


PHX 


PHzL 


cpzL 

ABS 


CMP 
ABSX 


DEC 
ABSX 


BBSS 
ZP 


CPX 
IMM 


SBC 
INDX 


LDA"- 
IDSP 


INW- 
ZP 


CPX 
ZP 


SBC 
ZP 


INC 
ZP 


SMB6 
ZP 


INX 


SBC 

IMM 


EOM 
NOP 


ROwL 
ABS 


CPX 
ABS 


SBC 
ABS 


INC 
ABS 


BBS 6 
ZP 


BEQ 
REL 


SBC 
INDY 


SBC 
INDZ 


beqL 

WREL 


phdL 

IMM 


SBC 
ZPX 


INC 
ZPX 


SMB7 
ZP 


sed 


SBC 
ABSY 


PU 


PLzL 


phdL 

ABS 


SBC 
ABSX 


INC 
ABSX 


BBS 7 
ZP 



B 



System Specification for C65 Fred Bowen - - ^ March 1, 1991 

2.4 The CSG 4567 System/Video Contxoller- 

2,4.1 Desciription 

The CSG 4567 is a low-cost high-peformance system/video controller, 
designed to be used in a wide variety of low-end home-computer type . 
systems ranging from joystick controlled video games to high-end 
home-productivity machines with built-in disk drives and monitor. The 
4567 was designed with Commodore-64 -(C64) architecture as a subset of 
its advanced features. In addition to having all of the C64 video 
modes, it also supports the character attributes - blink, bold, 
reverse video, and underline, and can display any of the new or old 
video modes in 80 column or 640 horizontal pixel format, as well as 
the older 40 col\imn 320 pixel format. 

A new "bitplane" video mode was added to allow the displaying of true 
bitplane type video, with up to eight bitplanes in. 320 pixel mode and 
up to four in 640 pixel mode. The 4567' can also time-multiplex the 
bitplanes to give a true four-color 1280 pixel picture. Vertical 
resolution is maintained at 200 lines as standard, but- can be doubled 
to 400 with interlace. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.4.2 CSG 4567 Pin Assiqnmen-bs 

(*** Pinout will change with 4567R7 ***) 



PSrNC 

CASS 

DISK* 

HEMCLK 

VCC 

DO 

EO 

Dl 

El 

D2 

E2 

D3 

E3 

D4 

£4 

D5 

E5 

D6 

EG 

07 

E7 



74 
73 
72 
71 
70 

es 

68 
67 

66 
65 
64 
63 
62 
61 
60 
59 
5fi 
57 
56 
55 
54 



RBGCSFSRRRII 

VVVVYGIOOOOO 

IIIINBDMMM21 

DDDDCG*LH*** 

E E E E * * 





N A R N E G 

E W X A 

1 C M R M 
A E 

P M 



CSG 4567 



7 7 77788888 
56789012341234 



5 6 7 8 9 



1 1 
1 



555544444444443333333 
321098765432109876543 

VXRLEEAAAAAAAAAAAAAAA 
SREPXX012345678911111 
SQS*TT 01234 

* * H V 
* * 



12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 



CAS* 

CASB* 

CASA* 

RAS* 

CPDCLK 

DOTCLK 

XTAL14 

XTAL17 

MAO 

MAI 

MA2 

MA3 

MA4 

MAS 

MA6 

MA7 

MB7 

MB6 

MBS 

A16 

A15 



System Specification for C65 Ered Bowen . March 1, 1991; 

2.4.3 CSG 4567 Operation 

The 4567 accesses two 8-bit memory blocks, which are up to 64K.each, 
via two 8-bit bidirectional busses. These are D0-D7 and E0-E7. The D0-D7 
bus is common with the CPU chip, ROM, SID, and the expansion port*, and is 
used for system memory and bitplanes. The E0-E7 port is only ' connected to 
RAM, This RAM is used for COLOR RAM, attribute RAM, system memory, and 
bitplanes. 

To access these RAMs, the 4567 has two multiplexed address busses. 
These are MA0-MA7, and MB5-MB7. Lines MA0-MA4 are common to both 64K banks 
of RAM, but MA5-MA7 go only to bank A, and MB5-MB7 go only to bank B. 

There are four types of DMA accesses which the 4567 can perform. 
Remember that RAS* is asserted on every memory clock cycle. These are,,. 

mode operation CASA* CASB* ROM* 

1. 4567 reading both banks, XX 

2. 4 567 reading bank "A" X 

3. 4 567 reading ROM X 

4. 4567 doing refresh. 

There are six types of CPU routings to RAM and peripheral devices that 
rre handled by the 4567. 

mode operation CASA* CASB* ROM* 

2. CPU reading bank "A". X 

3. CPU reading bank "B". X 

4. CPU writing bank "A". X 

5. CPU writing bank "B". X ' 

6. CPU reading ROM X 

7. CPU accessing I/Ol, 1/02, 
SID, ROMH, ROML 

The-e are four basic data routings through the 4567 chip. Three internal 
signals rout the data busses. WTREG (write 4567 register) enables routing the 
external D0-D7 bus to the internal register data bus. It is normally a logic 1 
When xt is brought low, the internal bus disconnects, and the D0-D7 bus output 
-^rivers turn on. This is for CPU reads of 4567 registers or "B" bank RAM. 
3BMEM (read "B" bank memory) routs the E0-'E7 data bus to the inputs of the 
^. '0-07 bus .output drivers when at logic level 1. This is for CPU reads of "B" 
bank RAM. When 0, (normal) the internal register data bus is routed to the 
D0-D7 bus output driver inputs, instead. WTBMEM (write B" bank memory) turns 
on the E0-E7 bus drivers, which directly routs the D0-D7 data bus to the E0-E7 
bus when 1. This is for CPU writes to the "B" bank RAM. When 0, , (normal) the 
0-E7 bus is input only. 

mode operation Wtreg RdBmem WtBmem 

1. CPU write 4567 register, 
CPU access external, 
4567 DMA, etc 10 (default) 

2. CPU read 4567 register 

3. CPU read B RAM 10 

4. CPU write B RAM 10 1 



System Specification for C65 Fred Bowen March 1, 1991 

DMA and Special CPU Accesses _' 

VMF — Video Matrix Fetch 

^n =,1/^5 tt^"^ performs Video Matrix Fetches, during displayed video times, 
WK in S^Sn"'"''?'-''^^ ^^^"^^ "^°*^®= ^SCM, MCM, ECM/bMM) . This is' true for 

both bLS ff r^m^ *^2° ^"^ ^^° P^^^^J "^°^^^- °"^i^^ ^' 'the 4567 reaL ■ 
both banks (A S B) of memory over both data busses D0-D7 and E0-E7. The D0-D7 
bus provides the video matrix data, E0-E3 provides color data, and E 4 -I 7 
provides character attribute data. 

CDF — Character Data Fetch 

M,^- • ^5\^5^? performs Character Data Fetches immediately after each Video 
Matrix Fetch m the original VIC-II modes except bitmap mode. During this fetch 
Character image data is fetched from ROM or RaU bank A over the D0-D7 b^s. 

BMF — BitMap Fetch 

Matrix^F^h^h^'^.n?''^- "^^K^^^'^fP ^^^^ Fetches immediately after each Video 
^t^i?J®^''5' """iy..^? ^^^ bitmap mode. During this fetch. Bitmap image data 
is fetched from RAM bank A over the D0-D7 bus. -^"xige aaT:a 

BPF — BitPlane Fetch 

i-^TH^. ^?? 4567 can perform Bitplane image fetches during displayed video 
fi?o^i ^^ the Bitplane mode (BPM) is enabled. The number and position of these 
fetches IS determined by which bitplanes are enabled. During bitplane fetchll 

RF — RAM refresh 

n^^ The 4567 performs six cycles of dynamic RAM refresh every scanned video 
line. During this time no data is fetched and CASA* and CASB^LInSt activated. 

SPF — Sprite Pointe:^ Fetch 

One SP?\!''^2nS^t-!ri^^ Pointer Fetches can occur each scanned video line. 

S?^r,r!Li ^^^f^^t®*^ f°J eajh sprite that is enabled and currently being 

?i^S fr ■^''''^"^.^" ^^^' t^® pointer to the sprite image data is fetched 

d5-S7 Sltrbus.^ ^^"^ ^""^^ ""^^^^ ^°^ ^^^ ^P^^^^ ^" Question over thf 

SDF ~ Sprite Data Fetch 

^y.-. J^""^^ Sprite Data Fetches follow each Sprite Pointer Fetch, During 
the DO-D?'dItrbus^^^^ ^^^ ^^""^^^ ^"^ question is f etch; d over ^ 

DAT — Display Address Translation 

Display Address Translation, or DAT fetches, are not actually DMA-tvpe 
accesses, but rather CPU address redirections to RAM. In this case, the 
unmuitiplexed address bus is totally separated from the multiplexed address bus. 

COL — Color RAM accesses 

Color RAM is also accessed by the CPU via an address translation. This 
IS because color RAM would otherwise be located in the I/O area! 



(. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Contents of the Internal A and B Memory 
Address Busses Prior to Multiplexing 



Sicrnal "VMF" "CDF" 



"BMF" 



"BPF" "RF" 



ngppw ngj^pt* "DAT" 



"COL' 



lAO 


VCO 


RCO 


RCO 


RCO 


RFO 


SFO 


SDO 


DTO 


AG 


lAl 


VCl 


RCl 


RCl 


RCl 


RFl 


SFl 


SDl 


DTI 


Al 


IA2 


VC2 


RC2 


RC2 


RC2 


Rr2 


SF2 


SD2 


DT2 


A2 


IA3 


VC3 


DO 


VCO 


VCO 


RF3 


1 


SD3 


DT3 


A3 


IA4 


VC4 


Dl 


VCl 


VCl 


RF4 


1 


SD4 


DT4 


A4 


IA5 


VC5 


D2 


VC2 


VC2 


1 


I 


SD5 


DT5 


A5 


IA6 


VC6 


D3- 


VC3 


VC3 


1 


1 


DO 


DT6 


A6 


IA7 


VC7 


D4 


VC4 


VC4 


1 


1 


Dl 


DT7 


A7 


IA8 


VC8 


D5 


VC5 


VC5 


1 


1 


D2 


DT8 


A8 


^9 


VC9 


D6 


VC6 


VC6 


1 


1 


D3 


DT9 


A9 


1.A10 


VMO/VCIO 


D7 


VC7 


VC7 


RF5 


VMO/1 


D4 


DTIO 


AlO 


I All 


VMl 


CBO 


VC8 


VC8 


RF6 


VMl 


D5 


DTll 


1 


IA12 


VM2 


CBl 


VC9 


VC9 


RF7 


VM2 


D6 


DT12 


1 


IA13 


VM3 


CB2 


CB2/VC10 


BE13/VC10 


1 


VM3 


D7 


BE13/DT13 


1 


IA14 


VBO 


VBO 


VBO 


BE14 


1 


VBO 


VBO 


BE14 


1 


■^A15 


VBl 


VBl 


VBl 


BE15 


1 


VBl 


VBl 


BE15 


1 


A16 


A16 


A16 


A16 


A16 


RF8 


A16 


A16 


DTI 6 


1 


IBIO 


0/* 


* 


* 


* 


* 


* 


* 


* 


* 


IBll 


1 


* 


* 


* 


* 


* 


* 


* 


1 


IB12 


1 


* 


* 


* 


* 


* 


* 


* 


1 


IB13 


1 


* 


* 


B013/* 


* 


* 


* 


B013/* 


1 


IB14 


1 


* 


* 


B014 


* 


* 


* 


B014 


1 


IB15 


1 


*■ 


* 


B015 


* 


* 


* 


B015 


1 



DMA 



Legend : 



\v 



VC ~ Video ilatrix Counter ■ 

RC = Row Counter 

VM = Video Matrix Address 

VB = Video Bank Address 

CB = Character Generator Bank Address 

RF = Refresh Counter 

SF - Sprite Pointer Fetch Counter 

SD = Sprite Data Fetch Counter 

DT ~ Display Address Translator 

BE = Bitplane Even Pointer 

BO = Bitplane Odd Pointer 

A - Address Out = Address In 

D - Data fetched from previous fetch 

* :s "B" bus contents, same as "A" bus 

xxx/yyy * contents for 320/640 pixel modes 



System Specification for C65 Fred Bowen March 1, 1991 

Multiplexed Address Bus Generation 

wTi ^ j'^JiS ^ ??*? ? niemory address busses are multiplexed 2:1 to generate the 
MA and MB multiplexed address busses. Listed below are the primLy ad5?essSs 
used to generate the multiplexed row and column addresses. ' 

signal row column 



MAO 


AO 


A5 


MAI 


Al 


A6 


MA2 


A2 


A7 


MA3 


A3 


A8 


MA4 


A4 


A9 


MAS 


AlO 


A13 


MA6 


All 


A14 


MA7 


A12 


A15 



MBS BIO B13 
MB6 Bll B14 
MB7 B12 BIS 



ROM physical addresses 



0000 


New area A 


2000 


■ Basic 


4000 


New area B 


5000 


Character sets 


6000 


Kernal 



ROM can appear (to the 4567) at 1000-lFFF (bank 0) 

Th^ D^Mu ^j . , ^""^ 9000-9FFF (bank 2) 
The ROM address translates to 5000-5FFF 



System Specification for C65 




Fred 


Bowen 




March 1, 1991 ■ 


Contents of Memory map 


based on Loram, 


Hiram, 


Game, and Exrom 




L H 


G 


E 






Area 








> 


I 


A 


X 
















R R 


M 


R 




/ROML 


/ROMH 






/ROMH 




A A 


£ 





0000- 


8000- 


AOOO- 


COOO- 


DOOO- 


EOOO- 




M M 




M 


7FFF 


9FFF 


BFFF 


CFET- 


DFFF 


FFFF 




— — 


— 


— 


— — — 














X X 





1 


4KRAJyi 


EXT 


NADA 


NADA 


I/O 


EXT 







1 


X 


RAM 


RAM 


, RAM 


RAM 


RAM 


BAM 







X 





RAM 


RAM 


RAM 


RAM 


RAM ■ 


RAM 




1 








RAM 


RAM 


EXT 


RAM 


I/O 


ROM 




1 


1 


X 


RAM 


RAM 


RAM 


RAM 


I/O 


ROM 




1 








RAM 


RAM 


RAM 


RAM 


,r/o 


RAM * 


CG ROM off 





1 


X 


RAM 


RAM 


RAM 


RAM 


r/o 


RAM 




1 








RAM 


EXT 


EXT 


RAM 


I/O 


ROM 




1 1 


1 





RAM 


EXT 


ROM 


RAM 


I/O 


ROM 




1 1 


1 


1 


RAM 


RAM 


ROM 


RAM 


I/O 


ROM 




Color 


Palette 


ROM Programming 












index 


red 


green 


blue 


fg/bg 


I 


Q 


Y 


color 


— — — - 


- — 
















... 






























black 


1 




15 


15 


15 


1 








1.0 


white 


2 




15 








1 


.60 


.21 


.30 


red 


3 







15 


15 


1 


-.60 


-.21 


.70 


cyan 


4 




15 





15 


1 


.28 


.52 


.41 


magenta 


5 







15 





I 


-.28 


-.52 


.59 


green 


6 




O 





15 


1 


-.32 


.31 


.11 


blue 


7 




15 


15 





1 


.32 


-.31 


.89 


yellow 


8 




15 


6 





1 


.49 





^.54 


orange 


9 




10 


4 





1 


.33 





.36 


brown 


1 




15 


7 


7 


1 


.32 


.11 


.63' 


pink 


1 ^^ 




5 


5 


5 


1 








.33 


dark grey 


'■"■ -2 




8 


8 


8 


1 








.53 


medium, grey 


13 




9 


15 


9 


1 


-.11 


-.21 


.84 


light green 


14 




9 


9 


15 


1 


-.13 


-.12 


.64 


light blue 


15 

1 




11 


11 


11 


1 








.73 


light, grey 
* ... 



System Specification for C65 



Fred Bowen 



March 1, 199^1 



Horizontal Sync Counter Events 
(assuming HPOS reg=0) 



^°5 ?In^ ^^® ^^^^^ ^^° HCOONT steps are at half the primary clock 
rate, and 390 are at the primary clock rate, giving 520 counts for 910 
clocks. For PAL the first 388 HCOUNT steps are at the slow rate, and 132 
are at the faster clock rate, giving 520 counts for 908 clocks. 



EVENT 

VSYNCl START 
VSYNCl STOP 
VSYNC2 START 
VSYNC2 STOP 
HSYNC START 
HSYNC STOP 
HEQai START 
HEQUl STOP 
HEQU2 START 
HEQU2 STOP 
BURST START 
BURST STOP 
HBLANK START 
HBLANK STOP 



Clock -t-256 



513 

449 

58 

904 

513 

576 

513 

549 

58 

94 

576 

623 

478 

653 



769 

70S 

314 

250 W 

769 

832 

769 

805 

314 

350 

832 

879 

734 

909 



n 

384 
352 
157 
125 
384 
416 
384 
402 
157 
175 
416 
439 
367 
454 



HCOUNT 

384 
352 
157 
125 
384 
442 
384 
414 
157 
175 
442 
488 
367 
518 



Duration 
846 59us 
846 59us 
63 4 . 4us 
36 2.5us 
36 2.5us 
47 3.3us 
175 12.2US 



■r , 



Horizontal DMA Counter Events 
(these are actual counts — decode 1 count earlier) 



Event 

HDMAEN START 
HDMAEN STOP 
HDER START 
HDEN STOP 
HPIXEN START 
HPIXEN STOP 
SPR GO 
SPR STOP 
SPR CLOCK DIS 
SPR CLOCK ENA 
SPR DMA START 
SPR DMA STOP 
REFRESH START 
REFRESH STOP 
VINC 
HRES 

-DOG START 
DOG STOP 
SYNCO 
SYNCl 
SYNC2 
FAST 



HCOUNT 



15 

335 

25 

345 

24 

344 

358 

359 

360 

488 

372 

482 

4 82 

506 

370 

15 

16 

376 



1 

3 

390 



19 (640 mode) 

339 (640 mode) 

32 (38 col) 

336 (38 col) 



(i 



(and EOL) 



NTSC 



388 PAL 



•^y 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Vertical Timings 

When the vertical position register VPOS is set to zero by the. CPU, 
it actually is storing a compare value of 128, since the MSB of VPOS is 
inverted. This actually corresponds to raster count 256/ since the vertical 
event counter is counting half-lines. When the vertical event counter 
matches the VPOS register, the vertical sync, counter is reset to zero. 
Multiply the desired line for each event by 2 and subtract the nominal VPOS 
value of 256 to get the desired decode. If the result is negative add the 
modulo of the vertical event counter, which is 525 for NTSC and 625 for PAL. 
The "line" in these tables refer to raster lines, where line 50. is the first 
displayed line in a 25 row display. 

NTSC 



Event 



line 



V count - vpos decode 



VSYNC START 


11 


VSYNC STOP 


14 


VEQU START 


8 


VEQU STOP 


17 


VBLANK START 


8 


VBLANK STOP 


28 


EARLY START 


64 


EARLY STOP 


11 


LATE START 


11 


LATE STOP 


3 



22 


-234 


291 


28 


-228 


297 


16 


-240 


285 


34 


-222 


303 


16 


-240 


285 


56 


-200 


325 


128 


-128 


397 


22 


-234 


291 


23 


-233 


292 


6 


-250 


275 



PAL — timings begin 25 lines before NTSC because of 50 extra lines 



Event 



line 



V count - vpos decode 



VSYNC START 


-14 


-29 


VdYNC STOP 


-11 


-24 


VEQU START 


-17 


-34 


VEQU STOP 


-9 


-19 


VBLANK START 


-17 


-34 


VBLANK STOP 


3 _ 


6 


EARLY START 


39 


78 


EARLY STOP 


-14 


-29 


LATE START 


-14 


-28 


LATE STOP 


-22 


-44 



285 


340 


280 


345 


290 


335 * 


275 


350 * 


290 


335 


250 


375 


176 


447 


285 


340 


284 


341 


300 


325 



equ/sync is 15 half-lines 

for pal ■ 



Note : EARLY- and LATE active concurrently indicate GROSS. 
divide ratios (including external sync values) 



Counter 



Normal Early Late 



Gross 



NTSC vertical 


525 


524 


526 


540 


PAL vertical 


625 


624 


626 


640 


NTSC horiz 


910 


908 


912 




PAL horiz 


908 


906 


910 




horiz counter 


520 


519 


521 





System Specification for C65 
Nxunber of cycles per line 
In "slow" CPU mode 



Fred Bowen 



Total cycles no video 

40 column SCM, MCM, ECM, 

320 pixel BPM, 

640 pixel BPM, 

80 column SCM, 

320 pixel BPM, 

640 pixel BPM, 

Sprites 



65 



BMM, 
BP0-BP3 only, or 
BPO-BPl only no cost 
MCM, ECM, EMM, 
BP0-BP7, or 

BP0-BP3 subtract 

subtract 



40 
2 



March 1, 1991 



per active sprite 



Examples . . . 

No video on line 

40 column text or equiv. BPs (no sprites) 

80 column text or equiv. BPs (no sprites) 

80 column text or equiv. BPs, all sprites 



65 
65 
25 
9 — worst case 



227 memory cycles/line 
6 refresh 
0-32 sprite 
0,40,80,120,160 video 



fast 

277 

-6 

-32 

239 

no 

video 



slow 

138 
-3 

-16 

119 

1 

fetch 



total cycles/line 

refresh 
sprites 

avail CPU cycles/line (no video) 



2 

fetch 



3 

fetch 



4 

fetch 



cpucyc 239 199 159 119 79 

cpucyc 271 231 191 151 111 

cpucyc 119 79 79 39 39 

cpucyc 135 95 95 55 55 



all sprites (fast) 
no sprites (fast) 
all sprites (slow) 
no sprites (slow) 



k 



. t 



System Specification for C65 Fred Bowen . March 1, 1991 

2.4.4 Progranmiinq^ the new VIC (4567) 

The C4567R6 is a high perfonaance single chip video controller 
designed to bring exceptional graphics to low cost computer and game 
systems* It presently is available in NTSC and PAL versions to match 
European and North American television standards. 

The following are new features that are added as a superset of the 
old VIC-II video controller functions incorporated in the C4567R61 

a. NewVic mode 

b. 80 colximn character and 640 horizontal pixel mode 

c. Scan interlace and 400 line mode 

d. Character attributes (blink, highlight, underline, reverse) 

e. Fast clock mode (3.58 vs. 1.02 MHz) 

f . Bitplane mode 

g. Color palettes 
h. Additional ROM 
i. 1280H pixel mode 
j. Display Address Translator (DAT) 
k. Horizontal and vertical positioning 
1. External sync (Genlock) 
m. Alternate character set 
n. Chroma killer 

NewVic Mode 

After power-up and reset, the C4567R6 performs as if it were the "old" 
VIC chip. In this mode, none of the new features are accessible. The old 
VIC II registers appear at addresses $D000-$D3FF, echoed 16 times, every 
64 addresses, and any new registers within the 64 byte block will not exist. 

To put the C4567R6 into "NewVic" mode, the user must write first an 
$A5 and then a $96 to the KEY register. Once these values have been entered 
the C4567R6 will be in "NewVic" mode, and access to the "NewVic" registers 
"■nd modes will be possible. 

;^; To take the C4567R6 out of "NewVic" mode, simply write any value to the 
KEY register. After doing this, all of the new modes will be disabled. The 
registers that were programmed in "NewVic" mode will retain their current 
values. It should be noted, however, that since all old modes are available 
in new mode, there is little reason to exit new mode. 



h 






\bl 



V 



System Specification for C65 Fred Bowen March 1, 1991 

80 Column (character) or 640 Pixel {bitmap or bitplane) Mode 

You can put the C4567R6 into "80 Column Mode" or "640 horizontal pixel 
mode by setting the fl640 bit in control register "B", The normal' horizontal 
rendering is 40 columns or 320 pixels. 

In 80 column character mode, several things change. The Video Matrix 
becomes 2K bytes long, where it used to be IK in 40 column mode. The charac- 
ter color RAM also becomes 2K bytes long. The locations of these areas do 
not change from the prior convention, except that the low order video matrix 
address bit is not used in 80 column mode. Where the programmer used to have 
16 choices for locating the Video Matrix within a video banlc, in 80 column 
mode there are only 8 choices- 

Although the color RAM doubles in size to 2K bytes, the area provided 
for color RAM in the I/O map only allows for IK of color RAM. -To read or write 
the second IK of color RAM requires that you move CIAl, CIA2, I/Ol, and 1/02 
out of the way. To do this, set the "COLOR RAM QDCOO" bit in Control Register 

In 640 pixel bitmap mode, similar changes occur. The video matrix and 
color RAM double in size and are positioned in the memory map exactly as is 
done in 80 column character mode. The bitmap must now also double in size 
from 8K to 16K bytes. Because the total memory that the video matrix and the 
bitmap would require now exceeds the normal 16k byte video bank size, the 
video bank size has been doxibled from 16K to 32K for the bitmap only. The 
least significant video bank bit is ignored, and the high order character 
generator bank bit selects which half of the 3 2K .video bank that bitmaps 
will be fetched from. The video matrix is still fetched from the normal 16K 
video bank. 

In 80 column or 640 pixel mode, the sprite pointers are at the end 
of the 2K byte video matrix, where they used to be at the end of the IK byte 
video matrix, in 40 column or 320 pixel mode. The size, location, and 
resolution of sprites are not affected by any of the mode switches. 



1 ; 



System Specification for C65 Fred Bowen March 1, 1991. 

Interlace, and 400 Line Vertical mode 

The C4567R6 can interlace scan lines to give a true NTSC, 525 line screen 
(625 lines on PAL versions) , although the default, however, is a>'262 line non- 
interlaced screen {312 lines on PAL versions) . Set the INT b'it in control 
register "B" to a "1" if you want interlacing. 

The C4S67R6 can also give a 400 line vertical resolution, which is useful 
in the new Bitplane mode. Set the V400 bit, and the INT bit in control 
register "B" to a "1" to enable 400 line bitplanes. {see Bitplanes, below) 
The V400 switch will have no effect if the display is not interlacing. Also, 
although interlacing is permitted in all of the old video modes, the same 
data will appear on both odd and even rasters, even if the V400 switch is on, 

230 Horizontal Pixel mode 

The C4567R6 supports ultra-high resolution graphics by permitting the 
programmer to use 1280 pixel lines. This is enabled by setting the H1280 
and H640 bits in control register "B" to a "1". 

The 1280 pixels are acheived by time-multiplexing bitplane bits. This 
,s done by substituting the pixel clock for bitplane 7. This means that for 
the first half of each pixel, the color palette will be fed the normal color 
index. For the second half of the saime pixel, it will fed the normal index, 
plus 128. To utilize this feature, the user must program the color palette 
to perform the multiplexing function. 

The H1280 bit can also be set H640 off. This is a unique mode that 
allows the use of 320 and 640 horizontal pixel bitplanes simultaneously,. 



System Specification for C65 Fred Bowen March 1, 1991 

Character Attributes 

In NewVic mode, the C4567R6 supports four new character attributes which 
can be enabled by setting the ATTR bit in Control Register ^B", These are 
Blink, Highlight, Underlined, and Reverse Video characters. Any combination 
of these attributes can be enabled on a character by character basis, at any 
time. Certain combinations will have varying effects. (See table below) 
Attributes can also be applied to bitmap mode, and, to a. limited extent, to 
the new bitplane mode, (see Bitplanes, below) 

Blink is enabled by setting bit 4 .of the Color RAM location for each 
character requiring this attribute. The Blink attribute will either flash the 
character on and off, or will alternately enable and disable the other 
attributes, if any are selected. The blink rate is approximately 1 Hz. 

Reverse Video is enabled by setting bit 5 of the Color RAM location for 
each character requiring this attribute. Reverse Video is achieved by simply 
complementing the character image data for each character with this attribute. 
If the character is also underlined, the underline will be reversed, as well. 
Highlighted characters also will reverse. Blink, if ensUjled, will alternately 
enable and disable this attribute. 

Highlight is enabled by setting bit 6 of the Color RAM location for each 
character requiring this attribute. Highlight is achieved by adding 16 to the 
color index value. As in the past, the character color is determined by the 
index value stored in bits 0-3 of the color RAM. In many respects, bit 6 is 
merely another color select bit. What differs is that the Blink attribute 
can be used to blink between the "normal" color; and the "highlight*^ color. 
Both the character image, and its background can have unique highlight colors. 

To use the highlight attribute, effectively, color palette locations 16 
through 31 should be programmed to "h/ghlight** colors, (see Palette, below). 
Highlight colors don't have to be related to normal colors, but can.be anything, 

Underline is enabled by setting bit 7 of the Color RAM location for each 
character requiring this attribute. Underline is accomplished by forcing "1" 
character image data on the eighth raster line for each character with this 
attribute. If the Blink attribute is also selected, the underline will blink." 



System Specification for CSS Fred Bowen March 1, 1991 

Summary of Character Attributes and their Effects 
Underline Hilite Reverse Blink Effect 



off 


off 


off 


off 


off 


off 


off 


on 


off 


off 


on 


off 


off 


off 


on 


on 


off 


on 


off 


off 


off 


on 


off 


on 


off 


on 


on 


off 


off 


on 


on 


on 


on 


off 


off 


off 


on 


off 


off 


on 


on 


off 


on 


off 


on 


off 


on 


on 


on 


on 


off 


off 


on 


on 


off 


on 


on 


on 


on 


off 


on 


on 


on 


on 



normal character 

blinking character 

reverse video character 

alternate reverse/normal 

highlight character 

alternate highlight/normal 

highlight, reverse video 

alternate highlight-reverse/norraal 

underlined character 

normal char with blinking underline 

underlined reverse-video 

alternate underline-reverse/normal 

highlight underlined character 

alternate highlight -underline /normal 

highlight underlined reversed 

alternate hilite-underlined-rev/normal 



System Specification for C65 Fred Bowen March 1, 1991 

Fast Clock 

o.^. ^-J?^S?"^^ ^^® '^^^ system to run certain types of the old C64 software, 
^®i no Provides a normal (slow) CPO clock with a long term (63us) average 
.of 1.02 Mhz (exactly the C64 clock rate). This is accomplished by setting up 
a pattern of 1.79Mhz (560ns) cycles to give a total of 65 cycles be horizontal 
scanning line (also, like C64) . In addition, logic is provided on the C4567R6 
to determine when the microprocessor chip is executing an enhanced opcode, and, 
if so, subtracts a clock cycle from it, r- ^ f 

^v. o-.f?-,«1^^^"^,'^^® ^^^"^ ^^^ ^" Control Register "B", you can instruct 
the C4567R6 to clock the CPU at 3.58 Mhz. and permit the microprocessor to 
execute Its enhanced instructions at full speed. This can increase CPU speed 
up to 400%. '^ 

BitPlane mode 

4-v- ^-r5^f?^^^^°" ^° ^^^ usual video modes provided by the old VIC chip, 
the C4567R6 provides a bitplane mode, which allows up to eight bitplanes to 
be used in the 320, or up to four bitplanes to be used in the 640 horizontal 
pixel modes . 

Enabling BitPlane mode is done by setting the BPM bit in Control 
Register "B".- Doing this will override all of the other video modes. To 
specify which bitplanes (0-7) to use, set the corresponding bit for each 
bitplane you want, m the Bitplane Enable register. Bitplane mode may be 
used with sprites. Bitplane 2 is the foreground/background plane used for 
sprite/background collision detection and priority. 

The bitplanes, whether enabled, or not, provide the eight color value 
bits used to define what color will be? displayed for any pixel on the screen. 
Bitplane provides the least significant bit of the color value, and bitplane 
7 provides the most significant bit. Bitplanes that are not enabled will 
contribute a "0" to their bit position in the color select code, unless the 
complement bit for that bitplane, in the complement register, is set. 

^^ ^l bitplane' s data can be inverted, whether or not the bitplane is 
enabled by setting its respective bit in the Bitplane Complement register. 
Inversion on unenabled bitplanes will cause them to contribute a "1" 
instead of their usual "0". 



System Specification for C65 Fred Bowen March 1, 1991 , 

In BitPlane itiode, the C4567R6 does not use the Video Bank select bits, 
like the old VIC chip did. Instead, You can specify which 8k block (in 320 
mode) , or which 16k block (in 640 mode) of memory you want a bitplane to 
come out of. Specify where you want the bitplanes to be fetched from, using 
Bitplane Address registers through 7. Note, however, that the least 
significant bits of these registers are ignored in 640 pixel" mode, and that- 
register 4 through 7 are never used in 640 pixel mode. Even nujobered bitplanes 
can only be fetched from memory bank (addresses 0-FFFF hex) , and odd 
numbered bitplanes can only be fetched from memory bank 1 (addresses 10000- 
IFFFF hex) . So, the bitplane pointers define which section within the 
confined bank that bitplane data will be fetched from. 

In the Bitplane address registers, there are two bit-fields. One field 
of bits is for the even vertical scan, and the other field of bits is for the 
odd scan. The odd scan bits are not used unless both INT and V400 bits are 
set in control register "B". 



Attributes can be enabled in bitplane mode by setting the ATTR bit in 
control register "B" . If this is done, the most significant nybble of bytes 
fetched for bitplane 3 will contain the attribute specification for each 
8 by 8 pixel cell, exactly as is done in character modes. One exception is 
that the "hilite" attribute will be disabled. The attributes are only applied 
■■o bitplane 2, which is also the foreground/background plane for sprite 
collisions and priority purposes. 

To properly utilize this feature, bitplane 2 must be enabled to 
provide attributed bitplane data, and bitplane 3 must be disabled, since it 
will be providing attribute data. Data fetches for the attribute data will 
occur, because bitplanes 2 and 3 are both fetched in the same memory cycle. 
You may also enable any other bitplanes as needed. Bitplane 2, and any other 
bitplane may be complemented, but complementing bitplane 3 will only cause its 
bit weight to contribute a "1", and will not invert the attribute data. 

Note; 

Addresses 1F800-1FFFF hex are the Color and Attribute RAM used in 
the old video modes. You can use this area for bitplane if you do not plan 
on switching between old and new video modes and expect the data for both 
lodes to be there. 



System Specification for C65 Fred Bowen March 1, 1991 

Color Palette 

The C4567R6, allows the programmer to use the sixteen standard "064" 
colors, or define up to 256 custom colors and/or use the palette to perform 
boolean operations on the bitplane data. The C4567R6 incorporates a 16 word ' 
palette ROM and a has a 256 word palette RAM. Each palette location is an 
index, which can specify one of sixtten possible intensity values (4 bits) 
each, of Red, Green, and Blue primary colors, plus a single control bit (FGBG) 
which can be used for foreground/background control for video mixing appli- 
cations, or to drive a separate monochrome screen. 

The first 16 locations of the palette default to the C64 colors in ROM 
The remaining 240 locations are programmable RAM. The first 16 locations can 
also be replaced with RAM, however, by setting the PAL bit in control register 

B . All old video modes, including sprites and exterior, can only access the 
lowest 16 palette locations (except hilite cells), so you may want to reserve 
these indices for such features. 

Only bitplane mode can make full use of all palette locations. Even when 
less than eight bitplanes are used, the bitplane complement bits of the unused 
Ditplanes can be used to specify which part of the palette is to be used. This 
feature allows the programmer to define multiple sub-palettes, which can be 
switched between quickly, or to specify an offset in the color table for 
the bitplanes, allowing separate colors for exterior and sprites. 

T,*„ ,^5 ®®^ ^^^ color palette, the user must simply write to the color palette 
RAM. Addresses DIOO-DIFF (hex) program the 256 Red values, addresses D200-D2FF 
(hex) program the 256 Green values, and addresses- D300-D3FF (hex) program the 
256 Blue values. All 256 locations of both the blue and green palettes are only 
4 bits wide, so the upper four data bits do nothing. Bit 4 of every red palette 
location IS the FGBG prograjnming bit, the remaining 3 bits are not used. The 
palette locations are not readable by ^the CPU. 



System Specification for C65 Fred Bowen 

C4567R6 Registers 



March 1, 1991 



MEMORY MAP SELECT AKD ENaBLE REGISTERS 

(EN BIT MUST BE 1 FOR SELECT TO BE 0) 
"4510" PORT 













EN2 


ENl 


ENO 












CHREN 


HIRAM 


LORAM 



0000 

0001 



VIC-II MODE REGISTERS 



S0X7 


S0X6 


S0X5 


S0X4 


S0X3 


S0X2 


SOXl 


SOXO 


S0Y7 


S0Y6 


S0Y5 


S0Y4 


S0Y3 


S0Y2 


SOYl . 


SOYO 


S1X7 


S1X6 


S1X5 


S1X4 


S1X3 


S1X2 


SlXl 


SIXO 


S1Y7 


S1Y6 


S1Y5 


S1Y4 


S1Y3 


S1Y2 


SlYl 


SlYO 


S2X7 


S2X6 


S2XS 


S2X4 


S2X3 


S2X2 


S2X1 


S2X0 


S2Y7 


S2Y6 


S2Y5 


S2Y4 


S2Y3 


S2Y2 


. S2Y1 


S2Y0 


S3X7 


S3X6 


S3X5 


S3X4 


S3X3 


S3X2 


S3X1 


S3X0 


S3Y7 


S3Y6 


S3Y5 


S3Y4 


S3Y3 


S3Y2 


S3Y1 


S3Y0 


S4X7 


S4X6 


S4X5 


S4X4 


S4X3 


S4X2 


S4X1 


S4X0 


S4Y7 


S4Y6 


S4Y5 


S4Y4 


S4Y3 


S4Y2 


S4Y1 


S4Y0 


S5X7 


S5X6 


S5X5 


35X4 


S5X3 


S5X2 


S5X1 


S5X0 


S5Y7 


S5Y6 


S5Y5 


S5Y4 


S5Y3 


S5Y2 


S5Y1 


S5Y0 


S6X7 


S6X6 


S6X5 


S6X4 


S6X3 


S6X2 


S6X1 


S6X0 


S6Y7 


S6Y6 


S6Y5 


S6Y4 


S6Y3 


S6Y2 


S6Y1 


S6Y0 ' 


S7X7 


S7X6 


S7X5 


S7X4 


S7X3 


S7X2 


S7X1 


S7X0 


S7Y7 


S7Y6 


S7Y5 


S7Y4 


S7Y3 


S7Y2 


S7Y1 


S7Y0 


S7X8 


S6X8 


S5X8 


S4X8 


S3X8 


S2X8 


S1X8 


S0X8 



















SD000+ 

00 SPRITE X 

01 SPRITE Y 

02 SPRITE 1 X 

03 SPRITE 1 Y 

04 SPRITE 2 X 

05 SPRITE 2 Y 

06 SPRITE 3 X 

07 SPRITE 3 Y 

08 SPRITE 4 X 

09 SPRITE 4 Y 
OA SPRITE 5 X 
OB SPRITE 5 Y 
OC SPRITE 6 X 
OD SPRITE 6 Y 
OE SPRITE 7 X 
OF SPRITE 7 Y 

10 SPRITE X 8 



System Specification for C65 



Fred Bowen 



March 1, 1991 



















RC8 


ECM 


BMM 


BLNK 


RSEL 


YSCL2 


YSCLl 


YSCLO 


RC7 


RC6 


RC5 


RC4 


RC3 


RC2 


RCl 


RCO 


LPX7 


LPX6 


1^X5 


LPX4 


LPX3 


LPX2 


LPXl 


LPXO 


LPY7 


-LPY6 


LPYS 


LPY4 


LPY3- 


I.PY2 


LPYl 


LPYO 


SE7 


SE6 


S£5 


SE4 


SE3 


SE2 


SEX 


SEO 






RST . 


HCM 


CSEL 


XSCL2 


XSCLl ' 


XSCLO 


SEXY7 


SExre 


SEXY5 


SEXY4 


SEXY3 


SEXY2 


SEXYl 


SEXYO 


VS13 


VS12 


VSll 


VSIO 


CB13 


CB12 


CBll 




IRQ 








LP IRQ 


ISSC 


ISBC 


RIRQ 










MT.PI 


MISSC 


MI SBC 


MRIRQ 


BSP7 


BSP6 


BSP5 


BSP4 


BSP3 


BSP2 


BSPl 


BSPO 


SCM7 


SCM6 


SCM5 


SCM4 


SCM3 


SCM2 


SCMl 


SCMO 


SEXX7 


SEXX6 


SEXX5 


SEXX4 


SEXX3 


SEXX2 


SEXXl 


SEXXO 


SSC7 


SSC6 


SSC5 


SSC4 


SSC3 


SSC2 


SSCl 


SSCO 


SBC7 


SBC 6 


SBC5 


SBC4 


SBC 3 


SBC2 


SBCl 


SBCO 










B0RD3 


B0RD2 


BORDl 


BORDO 










BK0C3 


BK0C2 


BKOCl 


BKOCO 










BK1C3- 


BK1C2 


BKICI 


BIOCO 










BK2C3 


BK2C2 


BK2C1 


BK2C0 










BK3C3 


BK3C2 


BK3C1 


BK3C0 










SM0C3 


SM0C2 


SMOCl 


SMOCO 










SM1C3 


SM1C2 


SMICI 


smco 










S0C3 


S0C2 


SOCl 


soco 










S1C3 


S1C2 


SlCl 


SICO 










S2C3 


S2C2 


S2C1 


S2C0 










S3C3 


S3C2 


S3C1 


S3C0 










S4C3 


S4C2 


S4C1 


S4C0 










S5C3 


SSC2 


SSCl. 


SSCO 










S6C3 


S6C2 


S6C1 


S6C0 










S7C3 


S7C2 


S7C1 


S7C0 



11 Y SCROLL 
12" RASTER CNT 
13 LITEPEN X 
•14 LITEPEN Y 

15 SPRITE ENA 

16 X SCROLL 

17 SPR EXP Y 

18 VS/CB BASES 

19 INTERRUPTS 
lA INT MASKS 
IB BK/SPR PRI 
IC MC SPR 

ID SPR EXP X 
IE SPR-SPR COL 
IF SPR-BK COL 

20 EXT COLOR 

21 BKO COLOR 

22 BKl COLOR 

23 BK2 COLOR 

24 BK3 COLOR 

25 SPR MCO 

26 SPR MCI 

27 SPRO COLOR 

28 SPRl COLOR 

29 SPR2 COLOR 
2A SPR3 COLOR 
2B SPR4 COLOR 
2C SPR5 COLOR 
2D SPR6 COLOR 
2E SPR7 COLOR 



System Specification for C65 



Fred Bowen 



March 1, 1991 



VIC-III MODE REGISTERS 



KEY7 


KEY 6 


KEYS 


KEY 4 


KEY3 


KEY2 


KEYl 


KEYO 


ROM 
eEOOO 


CROM 
89000 


ROM 

QCOOO 


ROM 
@A000 


- ROM 
88000 


PAL 


EXT 
SYNC 


CRAM 
@DC00 


H640 


FAST 


ATTR 


BPM 


V400 


H1280 


MONO 


INT 


BP7EN 


BP6EN 


BP5EN 


BP4EN 


BP3EN 


BP2EN 


BPIEN 


BPOEN 


B0AD15 
ODD 


B0AD14 
ODD 


B0AD13 
ODD 




B0AD15 
EVEN 


B0AD14 
EVEN 


B0AD13 
EVEN 




1AD15 
ODD 


B1AD14 
ODD 


B1AD13 
OQD 




B1AD15 
EVEN 


BiAD14 
EVEN 


B1AD13 
EVEN 


■- 


B2AD15 
ODD 


B2AD14 
ODD 


B2AD13 
ODD 




B2AD15 
EVEN 


B2AD14 
EVEN 


B2AD13 
EVEN 




33AD15 
ODD 


B-3AD14 
ODD 


B3AD13 
ODD 




B3AD15 
EVEN 


B3AD14- 
EVEN 


B3AD13 
EVEN 




B4AD15 
ODD 


B4AD14 
ODD 


B4AD13 
ODD 




B4AD15 
EVEN 


B4AD14 
EVEN 


B4AD13 
EVEN 




B5AD15 
ODD 


B5AD14 
ODD 


B5AD13 
ODD 




B5ADL5 
EVEN 


B5AD14 
EVEN 


B5AD13 
EVEN 




B6AD15 
ODD 


B6AD14 
ODD 


B6AD13 
ODD 




B6AD15 
EVEN 


B6AD14 
EVEN 


B6AD13 

EVEN 




B7AD15 
ODD 


B7AD14 
ODD 


B7AD13 
ODD 




B7AD15 
EVEN 


B7AD14 
EVEN 


B7AD13 
EVEN 




BP7C0MP 


BP6C0MP 


BP5C0MP 


BP4C0MP 


BP3C0MP 


BP2C0MP 


BPICOMP 


BPOCOMP 


1 BPY8 


BPX6 


BPX5 


BPX4 


BPX3 


BPX2 


BPXl 


BPXO 


BPY7 


BPY6 


BPY5 


BPY4 


BPY3 


BPY2 


BPYl 


BPYO 


HP0S7 


HP0S6 


HP0S5 


HP0S4 


HP0S3 


HP0S2 


HPOSl 


HPOSO 


VP0S7 


VP0S6 


VP0S5 


VP0S4 


VP0S3 


VP0S2 


VPOSl 


VPOSO 



D000+ 
2F KEY 

30 CONTROL A 



31 CONTROL B 

32 BP ENABS , 

33 BITPLANE 
ADDRESS 

34 BITPLANE 1 
ADDRESS 

35 BITPLANE 2 
ADDRESS 

36 BITPLANE 3 
ADDRESS 

37 BITPLANE 4 
ADDRESS 

38 BITPLANE 5 
ADDRESS 

39 BITPLANE 6 
ADDRESS 

3A BITPLANE 7 
ADDRESS 

3B BP COMPS 

3C BITPLANE X 

3D BITPLANE Y 

3E H0RI2 PCS 

3F VERT POS 



System Specification for C65 



Fred Bowen ■ 



March 1^ 1991 



DAT MEMORY PORTS 



BOP 1X7 


B0PIX6 


BOP 1X5 


B0PIX4 


B0Prx3 


BOP 1X2 


BOPIXl 


BOPIXO 


B1PIX7 


B1PIX6 


B1PIX5 


B1PIX4 


BlPrX3 


B IP 1X2 


BlPIXl 


BIPIXO 


B2PIX7 


B2PIX6 


B2PIX5 


B2PIX4 


B2PIX3 


B2PIX2 


B2PIX1 


B2Pixa 


B3PIX7 


B3PIX6 


B3PIX5 


B3PIX4 


B3PIX3 


B3PIX2 


B3PIX1 


B3PIX0 


B4PIX7 


B4PIX6 


B4PIX5 


B4PIX4 


B4PIX3 


B4PIX2 


B4PIX1 


B4PIX0 


B5PIX7 


B5PIX6 


B5PIX5 


B5PIX4 


B5PIX3 


B5PIX2 


B5PIX1 


B5P1X0 


B6PIX7 


B6PIX6 


B6PIX5 


B6PIX4 


B6PIX3 


B6PIX2 


B6PrXl 


B6PIX0 


B7PIX7 


B7PIX6 


B7PIX5 


B7PIX4 


B7PIX3 


B7PIX2 


B7PIX1 


B7PIX0 
.... 



D0OO+ 
* 40 BITPLANE 

41 BITPLANE 1 

•42 BITPLANE 2 

43 BITPLANE 3 

44 BITPLANE 4 

45 BITPLANE 5 
4 6 BITPLANE 6 
47 BITPLANE 7 



COLOR PALETTES 









FG/BG 


RED3 


RED2 


REDl 


REDO 










GRN3 


GRN2 


GRNl 


GRNO 










BL03 


BLU2 


BLUl 


BLUO 



100-lFF RED 
200-2FF GREEN 
300-3FF BLUE 



COLOR/ATTRIBUTE RAM 



UNDER 



HILIT 



REVRS 



BLINK 



INDX3 



INDX2 



INDXl 



El 



INDXO D800-DBFF 



(DC0O-DFFF> 



VXDEO BANK SELECT AND ENABLE 
(EN BIT MUST BE 1 FOR VB TO BE 0) 

















i 














VBl 


VBO 














ENl 


ENO 



DDOO (WRITE) 
DD02 (WRITE) 



System Specification for C65 Fred Bowen- March 1, 1991 

Limitations of the C4567R6 
and How to Avoid Them 

Watch carefully, when particular mode changes take effect. You may 
change PAL, H1280, V400, BPM, ATTR, and H640 modes anytime. However^ the 
new mode selection will not take effect until after the last line of the 
current character row. This is intended to simplify split-screen programming. 
But, if you are using the DAT to access bitmaps or bitplanes, you must wait 
long enough after selecting a new H640 or V400 mode to guarantee that the 
C4567R6 is- in the mode you intended before doing. any DAT accesses. The DAT uses 
these bits to determine how to draw the image. 

If you wcmt to use all four 640x400 bitplanes, you will be limited to 
a maximum of 5 sprites having unique data. You can have more sprites, if they 
re permitted to share data. This limitation is due to the fact that sprite 
pointers and data must be fetched from the 16K video matrix which must also be 
shared with one of the bitplanes. The bitplane will use 16000 of the 16384 
bytes. This leaves 384 bytes, which would support 6 sprite data blocks of 
64 byteS/ each. But the sprite pointers must come out of the highest 
addressed block, thus leaving only 5 sprite data blocks available. 

If you really need 8 unique sprites, you can use four 640x384 pixel 
bitplanes. This is done by setting the row select bit to 24 row mode. 
This will give you a total of 16 blocks of 64. This is more than enough, so 
you can even have alternate sprite data blocks . 

Note that Sprites and Sprite coordinates are unaffected by screen 
resolution, meaning that in 640x400 screens, for example, the sprites are 
still the same size on the screen and are still positioned as if the display 
map were 320x200. In an 80-col\imn text, or 640-wide bitplane, screen a "dot" 
on a sprite will cover 2 pixels. 

Notg^ also that, in bitplane mode, sprites will only collide with 
"background" data which has bits "on" in bitplane 2. All other bitplanes 
will NOT cause a sprite-to-background-data collision. 



System Specification for C65 Fred Bowen March 1, 1991 

An Example of How to Program the Color Palette 
for 1280 Pixel Resolution and Driving FGBG 

for AvfL^f^^i""?"*® ^°''«"'n^B ""^^ ^ bitplanes to tiiue-iaultiplex into 1. So, 
for example, lets use BPO for "early" bytes and BPl for "late" bytes. 



+ + +. 



+ + +_ ^ 



i''l^"l5|4|3t2ll|0| early BPO 



+ +• 



+ + + + 



'^!6|5|413|2I1|0| late BPl 



+ + 

+ — + — + — +- 



.+ + + + 

+ — + — + — + — + — + — + 



|7E|7L|6E|6L|5E|5L14E|4L)3E!3L!2E|2L|lEilL|0E|0L| final output 

The early pixels will be interleaved with the late ones, as shown. 

■?' "^Ti^?^ V^^ ^° ^^^^"^ ^ pixel, you must decide which bitplane 
It wiix Joe in, and operate on its byte. 

Make sure the H1280 control bit is set. If it is, BP7 will be forced 
low for an early pixel, and high for a late pixel. Let's program the pllette 
to multiplex BPO early and BPl late and ignore BP2 and BpfT I want my 
B?3 drivf . fi4n\^^^?^' ^"^,^^^5e to be white, and, at the same ?ime^have 
be 1280 pixels? monochrome screen with the FGBG pin. (it too could 



System Specification for C65 Fred Bowen March 1, 1991 

Display Address Translator (DAT) 

The C4567R6 contains a special piece of hardware, known as the Display 
Address Translator, or DAT, which allows the programiner to access -the bitplanes 
directly. In the old VIC configuration, the bitmap was organized as 25 rows 
of 40 stacks of 8 sequential bytes. This is great for displaying 8x8 
characters, but difficult for displaying graphics. 

The DAT overcomes the original burden by allowing the programmer to 
specify the (X,Y) location of the byte of bitplane memory to be read, modified, 
or written. This is done by writing the (X,Y) coordinates to the BPX and SPY 
register, respectively. The user can then read, modify, or write the specified 
location by reading, modifying, or writing one of the eight Bitplane registers. 
There is one bitplane register for each bitplane. 

The DAT automatically determines whether to use 320 or .640 pixel mode, 
d whether to use 200 or 400 line mode. It will also use the areas specified 
or the bitplanes, using the Bitplane Address registers. 

Horizontal and Vertical Positioning 

The C4567R6 has two registers to allow the programmer to alter the 
^sitioning of the display relative to the borders of his CRT (television or 
monitor) . Initially the positioning registers are set to zero, to give C64 
standard positioning. These registers are signed, two's complement values 
which specify an offset from the default positions - 

Chroma Killer 

The C4567R6 provides analog RGB video, with sync on all colors, an 
analog luminance output, with sync, and an analog NTSC (or PAL on PAL versions) 
chrominance output. It also provides a separate digital video signal, and a 
separate digital sync. When using the C4567R6 with a black and white television 
receiver, it may be best to suppress the chrominance information. This can be 
done by setting the MONO bit in control register "B". 

iditional ROM 

The C4567R6 does all decoding for ROMs. It supports a total of 32K of 
ROM, which is 12K over what the C64 is configured for. This 12K of extra ROM 
is available in one 8K block at 8000 (hex) , and one 4K block at COOO (hex) . 
To enable ROM at these areas, set the ROMQBOOO or ROM@C000 bits in Control 
Register "A". (Note that there are other chips in the CSS whicl) extend this 
Idressing limitation. The C65 has a 1MB ROM built-in.) 

Alternate Character Set 

Ordinarily, the C4S67R6 will always fetch ROM-based character data from 
addresses DOOO-DFFF. If the CROM@9000 bit is set in control register "A", 
ROM-based character data will be fetched from addresses 9000-9FFF. This 
allows for an alternate ROM-based character set. 



i System Specification for C65 Fred Bowen. March 1, 1991 



Future Document Topics 

At a later time, this document may also describe the following C4567R6 
enhancements and features... 

Weatherfax Mode 
Multiple (2-8) playfields 
Play field prioritization 

Multiple CRT configurations using the' digital and analog video 
Multiple sub-palettes 

Mixing. 1280 pixel and 640 pixel bitplanes 
Using all 272 palette locations 

Transparency, highlighting^ and palette logic functions 
Use of the priority /collision bitplane with the sprites 
- Use of external Video RAM 



pecifi cation 


for C65 




Fred Bowen 


palette 




palett 


e 




addresses 




outputs 




BBBBBBBB 








F 
G 


PPPPPPPP 


RBRR 


GGGG 


EBBS 


B 


76543210 


3210- 


3210 


3210 


G 


00000000 


0000 


0000 


0000 





00000001 


1111 


1111 


1111 





00000010 


0000 


0000 


0000 





00000011 


1111 


1111 


1111 





00000100 


0000. 


0000 


0000 


1 


00000101 


1111 


1111 


1111 


1 


00000110 


0000 . 


0000 


0000 


1 


00000111 


1111 


1111 


1111 


1 


00001000 


0000 


0000 


0000 





00001001 


1111 


1111 


1111 





00001010 


0000 


0000 


0000 





00001011 


1111 


1111 


1111 





00001100 


0000 


0000 


0000 


1 


OOOOllOl 


1111 


1111 


1111 


1 


00001110 


0000 


0000 


0000 


1 


00001111 


1111 


1111 


1111 


1 


10000000 


0000 


0000 


0000 





10000001 


0000 


0000 


0000 





10000010 


1111 


1111 


1111 





10000011 


1111 


1111 


1111 





10000100 


0000 


0000 


0000 


1 


10000101 


0000 


0000 


0000 


■ 1 


10000110 


1111 


1111 


1111 


1 


10000111 


1111 


1111 


1111 


1 


10001000 


0000 


0000 


0000 





10001001 


0000- 


0000 


0000 





10001010 


1111 


1111 


1111 





10001011 


1111 


1111 


1111 





10001100 


0000 


0000 


0000 


1 


10001101 


0000 


0000 


0000 


1 


10001110 


1111 


1111 


1111 


1 


10001111 


1111 


1111 


1111 


1 



March 1, 1991 



Since BP7 is low, 
the early pixel matters. 
Only care about BPO data, 
since it supplies the 
early data. Notice how 
the RGB output is all I's 
only when BPO is a 1, 
regardless of what the 
other BP's are doing. 
This is how you program 
the palette to ignore 
certain bitplanes. 

Did you see how FGBG is 
a 1 only when BP3 is a 1 
regardless of other BPs?. 

Now BP7 is high. The late 
pixels are being output. 
Now, the RGB output is all 
I's only when BPl (the 
late BP) is a 1, regardless 
of what the other BPs are 
doing. This is how to time 
multiplex between planes. 

Notice, now, that FGBG is 
still a 1 only if BPS is 
a 1, regardless of the 
other BPs, like before. 
This makes FGBG immune to 
the mutiplexing* It also 
shows how you can mix 
modes on the same screen! 



Note that BP4, BPS, and BP6 will be zero unless I specifically ask them 
to be set to 1 in the Bitplane Complement register. So if they are zero, 
I do not need to program the rest of the palette. But I can program the 
other parts of the palette, and use the bitplane complements for BP4, BPS, 
and BP6 to switch between sub-palettes! 



System Specification for C65 Fred Bowen March 1, 1991 

VIC-II modes, enhanced VIC-II modes, and VIC-III modes. 

The VIC-III supports, what are called, "VIC-II" video modes. It also 
supports enhancements to the basic VIC-II modes. There are, also a. variety 
of all-new VIC-III modes. In order to utilize any enhanced VIC-II mode, or 
any VIC-III mode, a special keying sequence is required. 

VIC-II modes 

Standard Character Mode 
Multi-color Character Mode 
Extended Color Mode 
Bit Map Mode 
Sprites 

Enhancements available to VIC-II modes 

80 column character modes (vs standard 40 columns) 

640 X 200 pixel bit maps (vs standard 320 x 200) 

Programmable colors 

Character attributes — Underline, Blink, Reverse, Hilight 

Alternate character set 

Interlace 

VIC-III video modes 

Bitplane modes 

1280 pixel ultra-high resolution 

400 line operation 



System Specification for C65 Fred Bowen March 1, 1991 

Location of VIC-II video data in memory (Video Bank selection) 

The VIC-II modes can only access a maximum of 16K bytes of memory, 
out of a total of 64K of potentially available display memory. To "select 
which fourth of the 64K memory will be available for VIC-II video accesses, 
the user must specify which Video Bank to use. This is done by setting- 
bits and 1 in the Bank Select register (location DD02 hex) as shown. 

B it Vi de o Addr e s s 
1 Bank Range 



3 COOO-FFFF 

1 2 8000-BFFF 

10 1 4000-7FFF 

11 0-3FFF 

':e same two bits must be set to a 1 in an enable register (location 0DOO 
dx) in order for a data bit to be recognized. Both of these registers, 
T:hough write only, may have bits shared, elsewhere in the application 
system. If this is the case, care must be taken to preserve the other 
port bits not shown, here. 



The Video Matrix 

The Video Matrix is a block of memory used to store character-organized 
display data. Depending on whether the chip is in 40 column or 80 column 
display mode, it is 1024 or 2048 bytes long. Since the VIC-II modes can only 
access 16K bytes of mexaory, this means there are 16 or 8 places that the video 
matrix can appear within the 16K Video Bank, depending on whether 4 or 80 
column mode is selected. The location of the Video matrix is chosen by bits 
4 through 7 of the Memory Pointers register (address D018 hex) . Bit 4 has no 
effect in 60 column mode. 



System Specification for C65 



Fred Bowen 



March 1> 1991 



The Character Memory Block 

rh;,^^ J«^ Character Memory is a 2048 byte block of memory that contains 
?o displavTfx^ bi^^^f Character definition requires 8 bytes in o?der 
£L^^nv;^>.= Jj^ I character image. And there are 256 possible values 
f =^>.^H ==^^^^^er code, so 8 X 256, or 2048 locations are required. For 
^tS^^.^^^^^*=^^^,^^^^^ition stored in the character memory, the lowest of the 

liaht scan^Lnff ^rS ^"^^ ^^ ^""^ character represents the top oSfof 
?i« L!J • ^S^ °f the character. The leftmost pixel of each character is 
the most Significant bit (bit 7) of the respective character memory b^e 

« 1 ?^w?^ 5^? VIC-II modes can only access 16K bytes of memory, there are 
only eight choices where the Character Memory Block can be Wt;d: ThSt 

nmp^i°''^^^o^^^?'=^®^ ^y ^^^^ ^-3 °f the Memo^ Pointers register Uddress 
D018 hex). Special combinations of Character Memory Block and Vidio Bank 

CB bit VB bit Image hex 

3 2 1 10 source address 

(0-7FF)+VB 
(800-FFF)+VB 

D000-D7FF {C000-C7FF if CROM@C000) 
(10aO-17FF)+VB 

D000-D7FF (C0OO-C7FF if CROM@C000) 
(1800-1FFF)+VB 
(2000-27FF)+VB 
(2800-2FFF)+VB 
(3000-37FF)+VB 
(3800-3FFF)+VB 






X X 


RAM 


1 


X X 


KAM 


10 


X 


ROM 


10 


X 1 


RAM 


oil 


X 


ROM 


oil 


X 1 


RAM 


10 


X X 


RAM 


10 1 


X X 


RAM 


110 


X X 


RAM 


111 


X X 


RAM 



Color/Attribute Memory 

^noi^J-^''^^^'^ ^^ ^^ locations 1F800-1FFFF. The CPU, however caii access the' 
lit K^ ^u^S^^^'-^^o^S ^<^<^«sses D800-DBFF. It can access ^hleSirt 2048 
T^e Cpi°can a?so^f °°:^f ^ \' the COLeDCOO bit is set in control register A. 
J^Ij,^^" ^^'^ ^iso access Color /Attribute RAM directly at addresses 1F800- 



Standard Character Mode 

Standard Character Mode is selected bv writinc t-o i-h** ppm =nrf t^mm 
bits in Mode Register A (location DOU hex)f writing to thi mSI bit IT 

aocat!irS^^l\i;^r'''°" '''' '^'=*' ^"^ "^ writing^'t^^Con^ro^RegLt^r B 



System Specification for C65 Fred Bowen March 1, 1991 

2 . 5 CSG FOllx — CSS Disk Controller Chip gate array (preliminary) 
2.5.1 Description 

CSG4171-F011 Revision C 

The CSG4171-F011 is a low cost MFM disk interface. It tequires the use 
of an external 512 byte RAM as a data cache buffer. This interface can perform 
reads from and writes to MFM formatted diskettes, as well as free-format full 
track reads and writes. It can also format diskettes. Logic is also provided 
for timed head stepping and for motor spin-up. The FOll provides for 
expansion drive interconnect using a serial protocol for control and status 
signals. It also incorporates an index pulse simulator for drives that do not 
have an index sensor. 

Unlike its predecessors, the "C^ revision provides 

a. Active high local LED output. 

b. Correct remote DSKCHG status. 

c. Protection of control bits when changing drive selects. 

d. IRQ cleared on reset, 

e. Blinking of the local LED. 

f. Swapping of buffer halves for CPU access. 

g. Two new Digital Phase Locked Loop (DPLL) read recovery methods 
in addition to the original Full Correction (FC) algorithm. 

h. Improved capture range in Full Correction, 

i. Decoding for external disk registers. 

j. A one line to two line active low decoder for external hardware. 



System Specification for C65 
Read recovery options 



Fred Bowen 



March 1, 1991 



, . The FO 11 now provides 3 methods for recovering MFM formatted disk 
aata. £acn method has its own advantages and tradeoffs. This is how. they 

^ The read-recovery, or dibit counter divides the dibit period into 
sxxteen partitions or counts assuming no read data pulses occur or 
correctly positioned read pulses occur. When a read data pulse with 

rifSf^H-^"""^ i ??®'-^i'^?^'^^ occurs, the dibit counter will modify its count 
depending on whether Full Correction (FC) , Digital Phase Locked Loop (DPLL) 
or Alternate Phase Locked Loop (ALT) recovery methods are selected. 



DIBIT CELL 













1 


2 


3 


4 


5 


6 


7 


8 


9 


A 


B 


C 


D 


E 


F 









DIBIT COUNTER 



u 



READ DATA PULSE 



















8 


9 


A 


B 


C 


D 


E 


F 















NEW (FC) DIBIT COUNTER 



NEW DIBIT CELL 



In Full Correction (FC) the dibit counter -is forced to count eight 
after a read pulse is received. This is the equivalent of forcing the read 

Shi?! IL^^^ ''^''^^'' °^ ^^^-^^^ ^^^^- ^^^^ "^^t^°^ f^^iy compensatis for 
phase and frequency variation. It will tolerate a considerable range of 
bit frequency error at the cost of permitting a limited range of bit phase 



System Specification for C65 



Fred Bowen 



March 1, 1991 




















































1 


2 


3 


4 


5 


6 


7 


8 


9 


A 


B 


C 


D 


E 


F 









READ DATA PULSE 



DPLL RESULT 



ADD 1 



SDB 1 



In Digital Phase Locked Loop (DPLL) recovery, the dibit counter is 
incremented if a read pulse occurs early (before a dibit cell center) , 
decremented if a read pulse is late (after a dibit cell center), or counts 
normally if no read pulse occurs, or if a pulse occurs within a dibit cell 
center. This method has the ability to track a large range of bit phase 
ror, but, unfortunately can only handle a very narrow frequency error 
ange . 



DIBIT CELL 












1 


2 


3 


4 


5 


6 


7 


8 


9 


A 


B 


C 


D 


E 


F 









READ DATA PULSE 



ALT DPLL RESULT 



h+2 



•1 H h -1 



-2 —I 



In Aiternate Digital Phase Locked Loop (ALT) recovery, the dibit 
counter behaves exactly as it does in standard DPLL mode, except that if 
read pulse occurs more than 3 counts early, or 4 counts late, the counter 
is incremented or decremented by 2. Like DPLL, this method can tolerate 
a large range of bit phase error, but can also compensate for a larger 
'requency error range. 



System Specification for CSS 



Fred Bowen 



March 1, 1991 



u 



READ DATA PULSE 



DIBIT CELL 












1 


2 


3 


4 


5 


6 


7 


8 


9 


A 


B 


C 


D 


E 


F 









DPLL RESULT 



ADD 1 



SUB 1 



In Digital Phase Locked Loop (DPLL) recovery, the dibit counter is 
incremented if a read pulse occurs early (before a dibit cell center) , 
decremented if a read pulse is late (after a dibit cell center) , or counts 
normally if no read pulse occurs, or if a pulse occurs within a dibit cell 
center. This method has the ability to track a large range of bit phase 
ror, but, unfortunately can only handle a very narrow frequency error 
ange . 



u 



READ DATA PULSE 



DIBIT CELL 












1 


2 


3 


4 


5 


6 


7 


8 


9 


A 


B 


C 


D 


E 


F 









ALT DPLL RESULT 



h+2 



^1 H h -1 



-2 ^ 



In Alternate Digital Phase Locked Loop (ALT) recovery, the dibit 
counter behaves exactly as it does in standard DPLL mode, except that if a 
read pulse occurs more than 3 counts early, or 4 counts late, the counter 
is incremented or decremented by 2. Like DPLL, this method can tolerate 
a large range of bit phase error, but can also compensate for a larger 
"requency error range. 



System Specification for CSS 



Fred Bowen 



March 1, 1991 



46 


iJiiRIO 


low 


47 


LD 


low 


48 


CLK 


low 


49 


LOCAL 


low 


50 


TSTCLK 




51 


EXTREG 


low 


52 


A4 




53 


DRO 


low 


54 


CSl 


low 


55 


T.KD 


high 


56 


DIR 




57 


STEP 


low 


58 


PHO 




59 


DSKIN 


low 


60 


RES 


low 


61 


XTALl 




62 


XTAX.2 




63 


VENDOR 


low 


64 


vcc 




65 


OSLO 


low 


66 


CSHI 


low 


67 


GND 




68 


GND 





I/O exp serial control/status 

output exp direction of serio 

output exp shift clock 

input disk local drive available 

input test test clock 

output to external registers 

input cpu address 

output disk drive select 

input . cpu chip select external logic 

output disk panel LED 

output disk stepping direction 

output disk stepping command 

input cpu clock 

input disk disk inserted 

input cpu reset 

input crystal 

output crystal 

input vendor 

output to external logic 

output to external logic 



System Specification for 065 Fred Bowen March 1, 1991 

2.5.2.2 Signal Descriptions 

Processor Interface I.ines 

A0-A4 These five address inputs select which internal ot external 

register is to be read or written by the processor. 



RW 



RRW 
RCS 



The RW input determines whether a register will be written 
(RW=low) or read (RWs=high) by the processor. 



^0-Dl Eight bi-directional lines which transfer data to and from the 

processor during register reads and writes. These are normally 
inputs, but become driven outputs when CS and PHO are true. 

*^S The Chip Select is a low-true input that determines that a 

register read or write will occur when PKO becomes true. 

^^^ External hardware chip select input. This low-true signal, when 

asserted, will cause OSLO to go true (low) if A4 is low, 
or CSHI to go true (low) if A4 is high. 

^^° A high-true input that must be driven high by the processor 

to indicate that A0-A4, RW, and CS are valid. 

^^Q The Interrupt Request is an open-drain output that will sink 

current when an interrupt is requested by the FOll. IRQ will 
go low (true) when the BUSY status bit changes from true to 
false if IRQ is enabled. 

^^S The Reset is a low-true input used to reset internal events. 

When RES goes low (true) any command in progress will be 
terminated. RES will not, however, affect any control register 
bits . 

Buffer RAM Interface Lines 

RA0-RA8 These nine RAM Address outputs must be connected directly 
to nine of the external buffer RAM chip address inputs. 
These may be scrambled for PCB simplif ication. 

RD0-RD7 These eight bi-directional lines must be connected to the eight 
bx-directional data lines of the external buffer RAM. These may 
be scrambled for PCB simplification. RD0-RD7 are inputs except 
when RRW and RCS are low. Then they become driven outputs. 



-f 



The RAM Read/Write output must be connected to ;:he R/W input 
of the external buffer RAM to control reading and writing. 

The RAM Chip Select is a 1.0 Mhz clock of 50% duty cycle, and 
iS low at a time when RA0-RA8, RRW, and RCS are valid. It must 
be connected to the CS input of the external buffer RAM. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



RD 
WD 

WGATE 
WPROT 

.OCAL 

DRO 

DISKIN 

MOT 

LED 

SIDE 

3TEP 
DIR 



TKO 



INDEX 



Disk Drive Interface Lines 
{All disk signals are iow-true) 

The Read Data input expects a series of low-going pulses 
from the currently selected disk drive. 

The Write Data output provides a series of low-going pulses 
at all times to all drives. It represents the MFM encoded" 
data streeun used for disk writes - 

The Write Gate output, when true, causes the Write Data to 
be written to the diskette in the currently selected drive. 

The Write Protect input must indicate, when true, that the 
present diskette in the local drive must not be written to. 
The FOll will not assert WGATE if WPROT is true, and will 
not execute any write related commands. 

The Local Drive Available input must be grouded in systems 
that have a resident local drive 0, and must be tied to Vcc 
in systems that are diskless . This will permit drive to 
be configured externally. 

This output, when low, indicates that the local drive 
(Drive 0) is the currently selected drive. 

The Disk In Input must indicate when a diskette is physically 
in the local drive, and the drive is available for use. 

The Motor On output, when true, turns on the motor of the 
local disk drive only. (Also turns on local LED) . 



EElT^tt: 



The EEIfoutput, when true turns on the panel Light-emitting- 
diode of the local disk drive only. (Causes LED to BLINK) . 

The Side select output determines which side of the media 
is to be read or written. It is high (false) for side 0^ and 
low (true) for side 1. This output reflects the status of the 
SIDE control bit regardless of which drive is selected. 

The Step output provides a low-going pulse when a head stepping 
command is executed, regardless of which drive is selected. 

The Direction output indicates to the drives whether the 
read/write head is to step toward track (DIR=high) or away 
from track (DIR=low) when a step pulse is received. This 
output reflects the status of the DIR command register bit 
regardless of which drive is selected. 

The Track Zero input must determine when the read/write head 
of -the local drive is positioned over track zero. This input 
will not suppress stepping pulses. 

The Index pulse input must provide a low going pulse for each 
spindle rotation of the local drive, if the local drive has 
an index sensor. This input must be tied low if the local 
drive has no index sensor. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



SERIO 



LD 



CLK 



Expansion Drive Interface Lines 
(all expansion lines are low-true) 

The Serial I/O line is a bi-directional signal that is used 
to pass control to all external disk drives, and "to receive 
status information from them. It is a driven- output when LD 
xs high, and an input, otherwise. 

The Load Data output tells the external expansion ^drives 
when to update control information shifted off of the serio 
line, when to load status information for shifting, and when 
to drive the SERIO line, (This is discussed later.) 

The Clock output provides a 50% duty cycle clock at 250Kh2 
to be used by the external expansion drives for shifting 
control and status information in and out. 



XTALl 
XTAL2 



VENDOR 



TSTCLK 
CSLO 
CSHI 
EXTREG 



Other Signals 

These two lines form two poles of a series-resonant crystal 
oscillator circuit. XTALl is an input, and XTAL2 is an output. 
An S.OOOOMhz crystal should be used. 

The software Vendor identifier input determines whether the 
FOll will be capable of generating protect marks within 
the sector headers. Production units will not have this 
signal bonded, except those shipped to software vendors. This 
pin should be grounded at all times. 

The Test Clock input is used to reduce FOll test times. This 
pm should be grounded at all times. 

External hardware active-low chip select output. Goes low when 
CSl and A4 are both low. 

External hardware active-low chip select output. Goes low when 
CSl is low and A4 is high. 

External register active-low chip select output. Goes low when 
CS is low and A4 is high. 



^{ 



System Specification for C65 
2.5.3 Registers 

C4171-F011C Registers 



CONTROL 



Fred Bowen 



March 1, 1991 



COMMAND 



STAT A 



STAT B 



TRACK 



SECTOR 



SIDE 



DATA 



CLOCK 



STEP 



P CODE 



7 


6 


5 


4 


3 


2 


1 


• 


IRQ 


LED 


MOTOR 


SWAP 


SIDE 


DS2 


bsi 


DSO 




WRITE 


BEAD 


FREE - 


STEP 


DIR 


ALGO 


ALT 


NOBOF 




BUSY. 


DRQ 


EQ 


RNF 


CRC 


LOST ' 


PROT 


TKQ 






RDREQ 


WTREQ 


RUN 


WGATE 


DSKIN 


INDEX 


IRQ 


DSKCHG 






T7 


T6 


T5 


T4 


T3 


T2 


Tl 


TO 




S7 


36 


S5 


* 34 


S3 


S2 


31 


SO 




S7 


S6 


S5 


S4 


S3 


S2 


31 


SO 




D7 


D6 


D5 


D4 


03 


D2 


Dl 


DO 




C7 


C6 


C5 


C4 


C3 


C2 


CI 


CO 




S7 


S6 


S5 


S4 


S3 


S2 


SI 


SO 




P7 


P6 


P5 


. P4 


P3 


£^2 


PI 


PO 



RW 



1 RW 



2 R 



3 R 



4 RW 



5 RW 



6 RW 



7 RW 



8 RW 



9 RW 



A R 



System Specification for C65 Fred Bowen March 1, 1991 

Control Register 

(DROl ^H^fr^^F^^S control register is sent to both the local drive 
MOTOR J^H rln 2?^^? ^^f^fljy connected expansion drives (DR1-DR7) . The 
are sel^^S? Signals will be held for the local drive while oth^r drives 

IRQ When set, enables interrupts to occur, when reset clears 

ana disables interrupts. 
J^Sno I'hf se two bits control the state of the MOTOR and LED 
MOTOR P^^P^ts. When both are clear, both MOTOR and LED -outputs will 

be off .When MOTOR is set, both MOTOR and LED Outputs will 

oM^o °"* ^^®" ^^° ^® ^®^' ^^« ^^^ will "blink". 
SWAP swaps upper and lower halves of the data buffer 
as seen by the CPU, 

n^7^n<:n Zt^^ ^2l' ®®^? ^^® ^^^^ output to 0, otherwise 1. 
DS2-DS0 these three bits select a drive (drive thru drive 7) . 

Wien DS0-DS2 are low and the LOCAL input is true (low) the 

DRO output will go true (low) . 

Command Register 



WRITE 

READ 

FREE 



must be set to perform write operations. 

must be set for all read operations. 
QTir-ij allows free-format read or write vs formatted 
^J.^F write to 1 to cause a head stepping pulse. 
JJIR sets head stepping direction 

selects read and write algorithm. 0=FC read, 1=DPLL read, 

U-normal write, l^precompensated write 

selects alternate DPLL read recovery method. The ALGO bit 

must be set for ALT to work. 

clears the buffer read/write pointers 



ALGO 

ALT 

NOBUF 



■-( 



System Specification for CSS 
Status Registers 



Fred Bowen 



March 1, 1991 



•*: *.v '^^^ appropriate status bits are sampled from the local status inputs 
If the local drxve (DRO) is selected. Otherwise, those bits are sampled from 
the serxally connected expansion drive (DRl-DR?) , • 



BUSY 
DRQ 

EQ 

RNF 
CRC 

LOST 
PROT 
TKO 

RDREQ 

WTREQ 

RUN 

WGATE 

DSKIN 

INDEX 

IRQ 

DSKCHG 



command is being executed 

disk interface has transferred a byte 

buffer CPU/Disk pointers are equal 

sector not found during formatted write or read 

CRC check failed 

data was lost during transfer 

disk is write protected 

head is positioned over track zero 

sector found during formatted read 

sector found during formatted write 

indicates successive matches during find operation 

write gate is on 

indicates that a disk is inserted in the drive 

disk index is currently over sensor 

an interrupt has occurred 

the DSKIN line has changed 

this is cleared by deselecting drive 



Track Register 
Sector Register 
Side Register 

i^^=^«^^^ Track, Side and Sector registers are used in FIND operations to 
locate a given sector on a given track on a given side. 

Data Register 

=«^ "^i?® ^^^^ register is the CPU gateway to the data buffer for both read 
ana write operations. 

lock Register 

•^ "^5}! "^^^^^ register is used to define the clock pattern to be used to 
FF^'^hexf marks. This register should normally be written to 



System Specification for C65 Fred Bowen March 1, 1991 

Step Register 

The step register is used to time head stepping. This register is 
compared to a counter, which is clocked at 16Khz, giving a time of 62.5 
microseconds per count, allowing a maximum of 16 milliseconds of step 
time per step operation. 

Protect Code Register 

The Protection Code register is a read-only register that contains 
the protect code of the last sector read. If the last sector read does not 
contain a Protect Mark in its header, then this register, will contain zero. 

Legal commands are . . . 

hexcode notes macro function 

40 1,4,5 RDS Read Sector 

80 1,2 WTS Write Sector 

60 1,4,5 RDT Read Track 

AO 1,2 MTT Write Track (format) 

10 3 STOUT Head Step Out 

3-4 3 TIME Time 1 head step interval (no pulse) 

18 3 STIN Head Step In 

20 3 SPIN Wait for motor spin-up 

00 3 CAN Cancel any command in progress 

01 CLB Clear the buffer pointers 

Notes: 1, Add 1 for nonbuffered operation. 

2. Add 4 for write precompensation 

3. Add 1 to clear buffer pointers 

4. Add 4 for DPLL recovery instead of FC recovery. 

5. Add 6 for Alternattr DPLL recovery. 



'H 



System Specification for C65 Fred Bowen March 1, 1991 

2.5.4 Command Descriptions 

Execution of any legal command will cause the BUSY status to be set, 
and the IRQ, RNF, CRC, and LOST flags to be cleared. Execution of-the CANcel 
or CLearBuffer commands, or any write operation command with. the WPROT status 
set, or any illegal command, will not cause a normal BUSY condition. However, 
any write to either the Command Register or the Control register will 
automatically cause BUSY to be set for at least one round trip delay of 
transmission and reception of the serialized control and status signals. When 
BUSY gets reset, either by successful command completion, error termination, 
round trip completion, or by user cancellation, the IRQ flag will be set, 
and an interrupt generated, unless interrupts are disabled. 

The user may CANcel any operation in progress at any time using the 
CAN command to can it. Use of this command during write operations is not 
■•dvised. 

Unbuffered operations 

If the buffer pointers are held clear by setting bit in the command 
register while issuing a command, unbuffered operations will result. These 
are most useful for formatting a diskette. The DRQ flag in status register 
A indicates when a transfer has occurred to or from the disk. 

For read operations, DRQ set, indicates that a byte of data has been 
read from disk, and must be read by the CPU. Reading the data with the 
CPU will clear the DRQ flag. If the data is not read by the time another 
byte is read from the disk, the old data will be. overwritten and the LOST 
status flag will be set. The LOST flag will remain set until the next 
command is Written. 

For write operations, the user should supply the first byte of data 
either before, or shortly after issuing a write command. The DRQ flag set 
indicates that the byte has been written to disk, and the CPU must supply 
the next byte. When the CPU supplies a byte the DRQ flag will be cleared. 
If the CPU does not supply a new byte in the time that it is required by 
the disk interface, the previous byte data will be written, and the LOST 
"lag will be set. The LOST flag will remain set until the next command is 
vritten. 

Buffered operations 

Buffered operations can be monitored by reading status register A, 
The DRQ and EQ bits indicate the immediate status of the buffer pointers. 
During any operation, the EQ bit, when set, indicates that both the disk 
and CPU buffer pointers are pointing to the same location. This can mean 
that the buffer is full or empty, depending on what operation is, or will 
be performed. The DRQ bit set indicates that the disk was last to access 
the buffer, and clear indicates that CPU was last to access the buffer. 

For read operations, the disk interface will read bytes from disk 
into the buffer. This will set DRQ and clear EQ. The CPU may read data 
from the buffer at any time after this occurs, and can continue to read 
data until EQ goes high, indicating that the buffer is empty. CPU reads 
from the data buffer will clear DRQ. If data is read from disk, setting 
DRQ, and EQ also gets set, this indicates that the buffer is now full. 
One more byte read from disk will set the LOST flag. The LOST flag will 
remain set until the next command is written. This condition will not 
usually occur when performing sectored reads of 512 bytes or less, since 
that is the buffer size. 



For write operations, CPU data may be written to the buffer before 
executing a write command, but may also be supplied during the transfer. 
If the EQ flag is set after the CPU writes to the buffer, clearing DRQ, 
this indicates that the buffer is now full, and that the CPU should wait 
before stuffing more data. The the EQ flag goes high with DRQ high, this 
indicates that the disk interface has used all of the available data in 
tne buffer. If one more byte is written to the disk, the LOST flag will 
be set, indicating old buffer data has been written to disk. The LOST 
tiag will remain set until the next command is written. 

Data Transfer Commands 

Execution of any of the Data Transfer Commands must be performed 
assuming that the correct drive has been selected, the proper side has 
been selected, and the drive's motor is on and has had time to spin up. 
The read/write head(s) must be positioned over the track that data is to 
^l.^^f'^5^®"®^ ^? °5 ^^°"- ^^ ^^® status of the buffer pointers is not as 
expected or required, a buffer pointer clear should be performed before 
writing data or issuing commands. 

All write commands should be performed with all bits in the clock 

riffif^^L^^S to a -1" (FF hex). This register is used only for formatting 

diskettes. For all write operations, the WGATE status flag indicates when 
data is actually being written to the diskette. 

Sectored or formatted operations 

These operations differ from free-format commands in that the use 
of sectors is expected. Sectors are of fixed length, and are located and 
read or written automatically. The disk control logic will verify that 
the track/sector/side read from the address marks on the disk match the 
track/sector/side register contents before transferring any data. If the 
address marks do not match the addres. information supplied by the user 
Within 6 index pulses, the command will terminate, BUSY will be reset 
and the RNF (record not found) flag will be set. The RNF flag will 
remain set until the next command is issued. The RUN flag, when set, 

T^ft''??!^ ^^f? ^"^ ^P'u^^^ sector being accessed appears to be correct. 
This flag will reset when any part of the address mark does not match 
the expected data, or a successful completion occurs. Therefore, RUN 
can change states several times over a single track. 

RDS Read a Sector 

Writing a 40 (hex) to the "command register will cause the controller 
to execute a buffered RDS (read sector) command. Writing a 41 (hex) will 
execute an unbuffered RDS command. Add 4 to either command to select DPLL 
data recovery instead of the normal FC method. Add 6 to either command to 
select Alternate DPLL recovery instead of the FC method. 

The RpRSQ flag, when set, indicates that the requested sector has been 
found, and is now being read into the buffer. RDREQ will reset after the last 
byte of the sector is read. 

WTS Write a Sector 

Writing a 80 (hex) to the command register will execute a buffered WTS 
*"S !.^.^^^^°^* command. Add 1 to this command for unbuffered operation, 
ana add 4 xf write precompensation is desired. 

The WTREQ flag, when set,, indicates that the requested sector has been 
round, and is now being written from the buffer. WTREQ will reset after the 
last byte of the sector is written. 



U 



RDT Read a track 



, -^ ^5^^^"? ^ ^^ *^®^* ^° ^^® command register will initiate an unformatted 

■11 f® read. Add 1 to the command for unbuffered operation. Reading 
will begxn immediately, and will continue until user cancellation^ The data 
recovery logic will use address and data marks to align data to byte 
boundaries. Add 4 to either command to select DPIX data recovery instead of 
the normal FC method. Add 6 to either command to select Alternate DPLL 
recovery instead of the FC method. 

WTT Write a track 

Writing an AO (hex) to the command register will initiate a buffered 
''Si ? track operation. Add 1 to this command for unbuffered operation, and 
acta 4 to enable write precompensation. 

.nH wJ^^ «rite Track feature is usually only used for formatting diskettes, 
and will most likely be used m the unbuffered mode, since both data and 
clock must be supplied on a byte by byte basis. Write normal data with the 
clock register set to FF hex. Write special marks with missing clocks by 
writing an FB hex to the clock register. y s ^y 

A^ ^^JZ^'^^^^A^'^^'^i^^^ begins with the first index pulse after the command 
IS issued, and continues until the next index pulse. 

STIN, STOUT Step In and Step Out 

o ct. Waiting a 10 (hex) or 18 <hex) to the command register will initiate 
a step-in or Step-Out operation, respectively. The stepping pulse will be 
generated immediately, and BUSY will remain set for the duration of the 
stepping time specified in the STEP register., 

TIME General purpose timer 

«^^ ^"^^^^«So5 ^f, <^ex) to the command register will initiate a TIME 
operation BUSY will remain set for the duration of the time specified 
n the STEP register. No stepping pulse will be generated. 

SPIN Wait for motor spin-up 

Writing a 20 _ (hex) to the command register will cause BUSY to be set, 
and stay set for six index pulses. The RNF flag will be set at the end of 
^nis operation . 



CAN 



Cancel or "Can" the current operation 



Writing a to the command register will force cancellation of anv 
command m progress, and force BUSY to be reset after at least one round-trip 
serial control and status transmission and reception. 



CLB Clear buffer pointers 



w e^ Writing a 1 to the command register will unconditionally reset the 
buffer pointers. This should be considered a buffer clear operation, although 
the contents of the buffer are not affected. The BUSY flag will be set for 
at least one round-trip serial control and status transmission and reception. 



System Specification for C65 Fred Bowen March 1, 1991 

Full Track Writing and Formatting Diskettes 

Writing full-track data and formatting are very similar. Both will 
require that you generate the appropriate SYNC bytes, so that the* read 
data recovery logic can align the serial bitstream to byte boundaries. 
Both descriptions, below, will assume that the spindle motor ~ is on, and up ' 
to speed, and that the read/write head is positioned over the. track and 
Side to be written. 

Track Writes 

Full-track writes can be done, either buffered or unbuffered, 
however, the CLOCK pattern register has no buffer, and writes to this register 
must be done "one on one" . 

Write track Buffered 

issue "clear buffer" command 
write FF hex to clock register 
issue "write track buffered" command 
write FF hex to data register 
wait for first DRQ flag 
write Al hex to data register 
write FB hex to clock register 
wait for next DRQ flag 
write Al hex to data register 
wait for next DRQ flag 
write Al hex to data register 
wait for next DRQ flag 
write FF hex to clock register 

write your first data byte to the data register 
you may now use fully buffered operation. 

Write Track Unbuffered 

write FF hex to clock register 
issue "write track unbuffered" command 
write FF hex to data register 
wait for first DRQ flag 
write Al hex to data register 
write FB hex to clock register 
wait for next DRQ flag 
write Al hex to data register 
wait for next DRQ flag 

write Al hex to data register * 

wait for next DRQ flag 
write FF hex to clock register 
loop: write data byte to the data register 
check BUSY flag for completion 
wait for next DRQ flag 
go to loop 



System Specification for C65 



Fred Bowen 



March 1, 1991 



Formatting a track 

. , , . ^" order to be able to read or write sectored data on a diskette, 
the diskette MUST be properly formatted. If, for any reason, marks are ' 
missing or have improper clocks, track, sector, side, or length information 
are incorrect, or the CRC bytes are in error, any attempt to perform a 
sectored read or write operation will terminate with a RNF error. 

Formatting a track is simply writing a track with a strictly specified 
series of bytes. A given track must be divided into an integer number of 
sectors, which are 128, 256, 512, or 1024 bytes long. Each sector must 
consist of the following information. All clocks, are FF. hex, where not 
specified. Data and clock values are in hexadecimal notation. Fill any 
left-over bytes in the track with 4E data. 



quan 



data/clock 



12 


00 


3 


Al/FB 




FE 




(track). 




(side) 




(sector) 




(length) 


2 


(crc) 


23 


4E 


12 


00 


3 


Al/FB 




FB 


128, 




256, 




512, 


or 


1024 


00 


2 


(crc) 


24 


4£ 



description 

gap 3* 

Marks 

Header mark 

Track number 

Side number 

Sector number 

sector Length (0=128,1*256,2=512,3=1024) 

CRC bytes 

gap 2 

gap 2 

Marks 

Data mark 



Data bytes (consistent with length) 
CRC bytes 
gap 3* 



* you may reduce the size of gap 3 to increase diskette capacity, however 
the sizes shown are suggested. tr ^ , 



System Specification for CSS Fred Bowen March 1, 1991 

Generating the CRC 

, .. ,^'^^%9^^ ^S^f sixteen bit value that must be generated serially, one 
bit at a time. Think of it as a 16 bit shift register that is broken in 

^oncS icf^acS hi?. V^^ ?^ ^^^^' ^°^ "^"^'^ ^° ^^« following elgSt ?imes, 
(once for each bit) beginning with the MSB or bit 7 of the input byte. 

■'■' u^l^^nc^®^^^?^^?^^® °^ °^ ^^e MSB of the input byte and CRC 
bit 15. Call this INBIT. 

2. Shift the entire 16 bit CRC left (toward MSB) 1 bit position, 
shifting a into CRC bit 0. *' ^ ""f 

3. If -INBIT is a 1, toggle CRC bits 0, 5, and 12. 

p. ^ To Generate a CRC value for a header, or for a data field, vou must 
^t^^t ^2^^^^1^5« theCRC to all I's (FFFF hex). Be sure to CRC all by?ef of 

?RC £?tr^bits 8-?i?''Lri ?h^''^?'^i^^^r'-^^^2.°^^P"^ ^^^ ^°^t significant 
CKt, jayte (bits 8-15) and then the least significant CRC byte (bits 7-0) You 

may also CRC the two CRC bytes. If you do, the final CRC value should b4 
Shown below is an example of code required to CRC bytes of data. 

CRC a byte. Assuming byte to CRC in accumulator and cumulative 
CRC value in CRC (Isb) and CRC+1 (msb) . 

CRCBYTE LDX #8 ; CRC eight bits 

STA TEMP 
CRCLOOP ASL TEMP ; shift bit into carry 

JSR CRCBIT ; CRC it 

DEX 

BNE CRCLOOP 

RTS 

CRC a bit. Assuming bit to CRC in carry, and cumulative CRC 
value in CRC (Isb) and CRC+1 (msb) . 

CRCBIT ROR 

EOR CRC+1 ; MSB contains INBIT 

PHP 

ASL CRC 

ROL CRC+1 ; shift CRC word 

PLP 

BPL RTS 

EOR #$21 ' ^°^^^® ^^^^ °' 5/ and 12 if INBIT is 1 . . 

STA CRC 
LDA CRC+1 
EOR #$10 
STA CRC+1 
RTS RTS 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.5.5 FOll Disk Expansion Port Serial Protocol 






LED 



MOT 



STP 



DIR 



SID 



DS2 DSl 



DSO 



SPR 



DKX 



DKC 



IND 



PRT TKO 



SERIO 



Legend : 

Output s 

LED 

MOT 

STP 

DIR 

SID 

DS2-DS0 



Panel LED On 
Spindle Motor On 
Step Pulse 
Step Direction 
Side Select 
Drive Unit Select 



Inputs . 

TKO 

DKI 

DKC 

IKD 

PRT 

SPR 



Track Zero 
Disk Inserted 
Disk Changed 
Index 

Write Protect 
Spare input 



The SERIO pin is bi-directional, and is used for both transmission of 
drive control signals, and reception of drive status signals. The FOll 
will drive SERIO when LD is high. The selected remote unit must drive SERIO 
when LD is low. All SERIO bits -are low-true. SERIO will float high for non- 
existant drives, making all inputs look false. 

All remote units must clock in serial data on the falling edge of CLK, 
The remote units must update their control information on LD falling if the 
DS bits ma.tch the given unit. All remote units may load their status inputs 
when LD is high. Remote units shift out serial status on the rising edge of 
CLK. The FOll will not change LD coincident with CLK, nor will it drive 
SERIO when LD is changing. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.5.6 FPU Disk Taminq^ 



UJSDFFERED WRITE 



- 






CTAK 




— 


• 






1 r 


DRQ 




DTAK 














LOST 


__ 


tJNBOFFERED READ 


DTAK 




- 








— 


DRQ 




CTAK 














LOST 



System Specification for C65 



Fred Bowen 



March 1, 1991 



BUFFERED READ 



_fl OLJl_JlJL' 



DTAK 



Jl 



DRQ 

EQ 

CTAK 



r 



LOST 



BUFFERED WRITE 



J R 






CTAK 



DRQ 



JLJLR_^ 



EQ 



DTAK 



LOST 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2.6 



F016 Expansion Drive Controller 



2.6.1 Description 



NOTE THAT THE C65 DOS SDPPORTS ONLY ONE EXTERNAL F016 EXPANSION DRIVE *** 



*** 



CSG4101-F016 Pinout: 



Pin 



Name Active Dir 



1 


DS 


low 


2 


MOT 


low 


3 


SIDE 


low 


4 


WPR07 


low 


5 


TKO 


low 


6 


INDEX 


low 


7 


DR2 


low 


8 


DRl 


low 


9 


DRO 


low 


10 


GND 




11 


RES 


low 


12 


LED 


low 


13 


DIR 




14 


STEP 


low 


15 


SPARE 




16 


DSKIN 


low 


17 


SERIO 


low 


18 


CLK 




19 


LD 




20 


VCC 





output 

output 

output 

input 

input 

input 

input 

input 

input 

input 

output 

output: 

output 

input 

input 

I/O 

input 

input 



Type 



pullup 
pullup 
pullup 
power 



bidir 



power 



Description 

drive selected 

motor on 

side select 

write protect 

track 

index 

drive assign dipswitch 

drive assign dipswitch 

drive assign dipswitch 

master reset 
panel LED 
stepping direction 
stepping command 

disk inserted 
serial data 
serial data clock 
shift/load command 



System Specification for CSS 



Fred Bowen 



March 1, 1991 



Signal descriptions: 

RES The Reset is a low-true input used to reset internal flip-flops 
The DS (drive selected) output will go false (high) when RES 
is asserted (low) . 

WPROT The Write Protect input must indicate, when true, that the 
diskette in the attached drive must not be written to (the 
drive itself will inhibit writing, as well) , 

DR This output, when low, indicates that the attached drive 
is the currently selected drive. This signal will become 
false Chigh) upon RESet and when another drive is selected. 

DSKIN The Disk In Input must indicate when a diskette is physically 
in the attached drive, and the drive is available for use. 

MOT The Motor On output, when true, turns on the motor of the 
attached disk drive. 



LED 
SIDE 

STEP 
DIR 



TKO 



INDEX 



SERIO 



LD 



CLK 



The LED output, when true turns on the panel Light-emitting- 
diode of the attached disk drive. 

The Side select output determines which side of the media 
is to be read or written. It is high (false) for side 0, and 
low (true) for side 1. 

The Step output provides a low-going pulse when a head step 
operation is recpaired, assuming DS is true (low) . 

The Direction output indicates to the drives whether the 
read/write head is to step towaxd track (DIR=high) or away 
from track (DIR=low) when a step pulse is received, 
asstaming DS is true (low) . 

The Track Zero input must determine when the read/write head 
of the attached drive is positioned over track zero. 

The Index pulse input must provide a low going pulse for each 
spindle rotation of the attached drive, if it has an index 
sensor. The F016 will latch index pulses until they are sent 
out via the SERIO line. This input must be tied low if the 
attached drive has no index sensor. 

The Serial I/O line is a bi-directional signal that is used 
to receive control information from the main di^k controller, 
and return status information to the main controller, assuming 
the DS output is true (low) , It is a driven output when LD 
and DS are low, and an input, otherwise. 

The Load Data input tells when to update control information 
shifted over the SERIO line, when to load status . information 
for shifting, and when to drive the SERIO line. 

The Clock input is used for shifting control and status 
information. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



2,6.2 Expansion Fort Timing 



(used by all F016 chips) 



JTTiJinjTrLriniiJirLriiirij- 
r- ^ n ^ T- 



LED 


MOT 


STP 


DIR 


SID 


DS2 


DSl 


DSO 


SPR 


DKI 


DKC 


IND 


PRT 


TKO 



LD 



SERIO 



Legend: 

Outputs* . , 

LED Panel LED On 

MOT Spindle Motor On 

STP Step Pulse 

DIR Step Direction 

SID Side Select 

DS2-DS0 Drive Unit Select 



Inputs . 


. ; 


TKO 


Track Zero 


DKI 


Disk Inserted 


DKC 


Disk Changed 


IND 


Index 


PRT 


Write Protect 


SPR 


Spare Input 



The SERIO pin is bi-directional, and is used for both transmission of 
drrve control signals, and reception of drive status signals. The FOllB 
will drive SERIO when LD is high. Any selected FOIS will drive SERIO when LD 
is low. All SERIO bits are low-true. %ERIO will float high for nonexistant 
drives, making all inputs look false. 



All F016 chips clock in serial data on the falling edge of CLK. They 
update their control information on LD falling if the DS bits match the 
DSO-0S2 switch settings. Ai-1 F016 chips load their status inputs when LD is 
high, and shift out serial status on the rising edge of CLK. 



;i 



System Specification for C65 Fred Bowen . ■ March 1, 1991 

2 . 7 DMRq-ic DHR COKTROllLER FOIS (Preliminary) 

2.7.1 F018 DESCRIPTION 

DMAGIC is a custom DMA Gate array IC used in the C65. It 
functions as a DMA controller with a few tricks up its sleeve* 
Specifically, DMAgic provides the following commands: 

* COPY - Copy a block of memory to another area in memory. 

* MIX - Perform a boolean Minterm mix of a source block of 

memory with a destination block of memory. ' 

* SWAP - Exchange the contents of two blocks of memory. 

* FILL - Fill a block of memory with a source byte . 
Special features include: 

* List -based fetching of DMA command sequences. 

* Ability to CHAIN multiple DMA command sequences. 

* Absolute Address access to entire System Memory {8MB) . 

* Blocks can be up to 64K bytes long. 

* Windowed Block capability using MODulus function. 

* DMAgic operations yield to VIC video and external DMA accesses. 

* DMAgic operations can optionally yield to system interrupts. 

* Interrupted DMAgic operations can be continued/resumed, or 
cancelled. 

* Data ReQuest handshaking support for 10 devices. 

* Independent memory /mapped 10 selection for source and destination." 

* Independent memory tranfer DIRection for source and destination. 

* Independent MODulus enable for source and destination. 

* Independent HOLD (fixed pointer) for source and destination. 
The DMA controller has 4 registers; 

DMA List address low. Triggers DMA (write only) 

1 DMA List address high (write only) 

2 DMA List address bank (write only) 

3 DMA Status (b7=fbusy, bO-chained) (read only) 

(a read will restart an INTerupted DMA operation) 

Note: Minterns & Subcommand will not be implemented until F018A, at which 

time the register map will be reorganized & support for the REC added. 

dma ctlr = SD700 ;DMA Controller 



System Specification for C65 

2,7.2 F018 REGISTERS 



Fred Bowen 



March 1, 1991 



BEG R 

NAME # B7 



COMMAND 



B6 



F018 DMA CONTROLLER 
B5 B4 B3 B2 



Bl BO 



CNT LO 

(COL) 



CNT HI 
(ROW) 



SRC LO 

(FILL) 



SRC HI 



SRC BANK 5 



DEST lO 6 



DEST HI 7 



DEST BANK 8 



MOD LO 



MOD HI 10 



SADA 


SADA 


SADA 




INT 


CHAIN 


1 
OPERATION 

I 


SADA 




C7 


C6 


C5 


C4 


C3 


C2 


01 


CO 


CIS 


CI 4 


CI 3 


C12 


Cll 


CIO 


C9 


C8 




SA7 


SA6 


SA5 


SA4 


SA3 


SA2 


SAl 


SAO 


SA15 


SA14 


SA13 


SA12 


SAll 


SAl 


SA9 


SA8 


I/O 


DIR 


MOD 


HOLD 


SA19 


SA18 


SAl 7 


SAl 6 




DA7 


DA6 


DA5 


DA4 


DA3 


DA2 


DAI 


DAO 


DAI 5 


DAI 4 


DAI 3 


DA12 


DAll 


DAIO 


DA9 


DAS 


I/O 


DIR 


MOD 


HOLD 


DAI 9 


DAI 8 


,DA17 


DAI 6 






M7 


M6 


MS 


M4 


M3 


M2 


Ml 


MO 


Ml 5 


M14 


Ml 3 


M12 


Mil 


MID 


M9 


MS 



System Specification for C65 



Fred Bowen 



March 1, 1991 



OPERATIONS: 



PARAMETERS; 






COPY 


' 


1 


MIX 


(MINTERMS ACTIVE) 


1 


SWAP 




1 1 


FILL 


{SRC LO = FILL BYTE) 



INT 



NO INTERRUPTION 

1 IRQ/NMI INTEKRUPTION 



CHAIN LAST COMMAND IN LIST 
1 PERFORM NEXT COMMAND 



BOOLEAN MINTERMS: 



SA 



■ 1 



DA 
1 





SADA 

1 


SADA 



SADA 
2 


SADA 
3 



THE ABOVE COMMANDS ARE NOT YET IMPLEMENTED, AND SOME OF THE REGISTER 
BITS DEFINED ARE DIFFERENT IN THE PILOT VERSIONS. 



System Specification for CSS 



Fred Bowen 



March 1, 1991 



2. 8 RflM Expansion Controller 
2.8.1 Functional Specification 



C65 RAM EXPANSION FUNCTIONAL SPECIFICATION 

*** THIS IS PRELIMINARY AND WILL BE CHANGING *** 

The C65 RAM Expansion Card (REC) provides 1 megabyte of 
expansion RAM for the C65 computer. The C65 4510/VIC-III provides 1MB 
of address space, but rudimentary banking capability is provided by 
the REC to allow several different memory configurations for both the 
CPU and the VIC-III via available chip selects. 



The REC presumes the following system memory map: 



$00000-$1FFFF 
$20000-$3FFFF 
S40000-$7FFFF 
$80000-$FFFFF 



128K internal RAM 

128K for internal System ROM 

256K reserved for cartridge expansion 

512K reserved for RAM expansion 



The REC contains a four-bit write-only register. Data is read from 
the four low-order bits of the data bus. Reset forces all of these 
bits into the reset (low) state. The four bits are defined as: 



/' 
//" 

3210 

xOxx 

xlOO 

xllO 
xlOl 
xlll 



_CPU bank select 
_VIC access enable 
yiC address range 
"vie Bank select 



VIC sees: 



Internal RAM 

Expansion RAM bank 0, physical address 

Expansion RAM bank 0, physical address 

Expansion RAM bank 1, physical address 

Expansion RAM bank 1, physical address 



S00000-$1FFFF 
$COO0O-$DFFFF 
$EOO0O-$FFFFF 
$00000- $DFFFF 
$EOO0O-$5FFFF 



CPU sees (note that DMA and VIC-DAT access see this too) 

Oxxx Expansion RAM bank 
Ixxx Expansion RAM bank 1 



System Specification for CSS 
/* Inputs */ 



Fred Bowen 



March 1, 1991 



PIN 1 


= MEMCLK , 




PIN 2 


= !CAS ; 


PIN 3 


« AZC ; 


PIN 4 


- B3 ; 


PIN 5 


= A19 




PIN 6 


= A18 




PIN 7 


= A17 




PIN 8 


« A16 




PIN 9 


« A7 ; 


PIN 10 


^ RW ; 


PIN 11 


= !SID ; 


PIN 13 


= B2 ; 


PIN 14 


= Bl ; 


PIN 23 


= BO ; 


* Outputs */ 


PIN 15 


= ICASOB ; 


PIN 16 


= ICASOA 




PIN 17 


= ICASIB 




PIN 18 


= ICASIA 




PIN 19 


= ! EXPAND ; 


PIN 20 


= MAS ; 


PIN 21 


= IBRDGOE ; 


PIN 22 


= EX_LArCH 


VIC 


= !AEC ; 


EAST 


= ! MEMCLK ; 


CAST 


= MEMCLK ; 


EXVIC 


= BO ; 


VICSELO 


= Bl ; 


VICSELl 


= y&2 ; 


CPUBANK 


= B3 ; 







/* 
/* 
/* 

/* 
/* 



System memory clock */ 

Correct timing for CAS signal */ 
The VIC is in town */ 

bit to control CPU accesses */ 
high order address lines */ 



/* Chip select for SID. Used as a decode */ 
/* bits to control VIC accesses */ 



/* Cases for the DRAMS */ 



/* Signal to system to allow internal ram out */ 

/* High order Memory address line DRAMS */ 

/* Enable for the Gardei Bridge */ 

/* Strobe for user write to control latch */ 



EX_LATCH = CAS & SID fi A7 6 ! RW ; /* location of control register */ 
/* latch data on cas fall to avoid the phi-2 hold time problem */ 



^RDGOE 
EXPAND 

MAS 



/* bank 

CASOA 
CAS OB 

/* bank 

CASIA 
CAS IB ■ 



= EXPAND & A16 & !VIC 



= !VIC 

# VIC 

~ VIC 

# VIC 

# !VIC 

# !VIC 



A19 
EXVIC 

RAST & 
CAST & 
RAST & 
CAST & 



!A16 

VICSELO 
A18 
A17 ; 



/* CPU accessing E bank side* */ 

/* ram area */ 

/* external vie accesses allowed*/ 

/* Ras time, keep upper**/ 

/* Cas time, programable. */ 

/* ras time */ 

/* cas time */ 



drams */" 

CAS & EXPAND 

CAS & EXPAND 

drams */ 

CAS & EXPAND 

CAS & EXPAND 



( !VIC 
( !VIC 



( !VIC 
( !VIC 



! CPUBANK 
! CPUBANK 



CPUBANK 
CPUBANK 



!A16 # VIC 
A16 # VIC 



!A16 # VIC 
A16 # VIC 



& IVICSELl ) ; 
& IVICSELl ); 



& VICSELl ) ; 
& VICSELl ) ; 



System Specification for C6S 



Fred Bowen 



March 1, 1991 



2.9 



8580 SID FEGISTER HAP 




1 
2 
3 
4 
5 
6 

7 

8 
9 
10 
11 
12 
13 

14 
15 
16 
17 
18 
19 
20 

21 
22 
23 
24 

25 

26 
27 
28 



7 


6 


5 


4 


3 


2 


1 





F7 


F6 


F5 


F4 


F3 


F2 


Fl 


FO 


F15 


F14 


F13 


F12 


Fll 


FIG 


F9 


F8 


Pff7 


Pff6 


PW5 


PW4 


PW3 


PW2 


PWl 


PWO 










PWil 


PWIO 


PW9 


PW8 


KOISE 


POLSE 


SAW 


TRI 


TEST 


RING 


SYNC 


GATE 


ATK3 


ATK2 


ATKl 


ATKO 


DCY3 


DCY2 


DCYl 


DCYO 


STN3 


STN2 


STNl 


STNO 


RLS3 


RLS2 


RlSl 


RLSO 


F? 


F6 


F5 


F4 


F3 


F2 


Fl 


FO 


FIS 


T14 


F13 


F12 


Fll 


FIO 


F9 


F8 


PW7 


PW6 


PW5 


PW4 


PW3 


PW2 


PWl 


PWO 










PWll 


PWIO 


PW9 


PWS 


NOISE 


POLSE 


SAW 


TRI 


TEST 


RING 


SYNC 


GATE 


ATK3 


ATK2 


ATKl 


ATKO 


DCY3 


DCY2 


Dcn 


DCYO 


STN3 


STN2 


STNl 


STNO 


RLS3 


RLS2 


RLSl 


RLSO 


F7 


F6 


F5 


F4 


F3 


F2 


Fl 


FO 


F15 


F14 


F13 


F12 


Fll 


FIO 


F9 


F8 


PW7 


PH6 


PW5 


PH4 


PW3 


PW2 


PWl 


PWO 










PWll 


PWIO 


PW9 


PW8 


NOISE 


POLSE 


SAW 


TRI 


TEST 


RING 


SYNC 


GATE 


ATK3 


ATK2 


ATKl 


ATKO 


DCY3 


DCY2 


DCYl 


DCYO 


STN3 


STN2 


STNl 


STNO 


RLS3 


RLS2 


RLSl . 


RLSO 












FC2 


FCl 


FCO 


FCIO 


FC9 


FC8 


FC7 


FC6 


FC5 


FC4 


FC3 


RES3 


RES2 


RESl 


HESO 


filte2 


FILT3 


FILT2 


FILTO 


3 OFF 


HP 


BP 


LP 


V0L3 


V0L2 


VOLl 


VOLO 


PX7 


PX6 


PX5 


PX4 


PX3 


_PX2 


PXl 


PXO 


PY7 


py€ 


PY5 


PY4 


py3 


PY2 


PYl 


PYO 


07 


06 


05 


04 


03 


02 


01 


00 


E7 


E6 


E5 


E4 


E3 


E2 


El 


EO' 



FREQUENCY LO VOICE-1 
FREQUENCY HI 
POLSE WIDTH LO 
POLSE WIDTH HI 
CONTROL REGISTER 
ATTACK / DECAY 
SOSTAIK / RELEASE 

FREQOENCY LO VOICE-2 
FREQUENCY HI 
POLSE WIDTH LO 
POLSE WIDTH HI 
CONTROL REGISTER 
ATTACK /■ DECAY 
SOSTAIN / RELEASE 

FREQOENCY LO VOICE-3 
FREQOENCY HI 
PULSE WIDTH LO 
POLSE WIDTH HI 
CONTROL REGISTER 
ATTACK / DECAY 
SOSTAIN / RELEASE 

FREQOENCY LO FILTER 
FREQOENCY HI 
RESONANCE / FILTER 
MODE / VOLUME 



POT X 
POT Y 

OSCILLATOR 3 
ENVELOPE 3 



MISC. 



Notes; * 

1. CIA#1 ports PRA6 and PRA7 select which control port POT line 
is routed to SID. 

2. While there are 2 SIDs in the 065, the POT lines are still 
routed to S1D#1 for C64 compatibility reasons. 



System Specification for C65 Fred Bowen March 1, 1991 

3-0 System Software 
3.1 BASIC 10.0 



C64DX BASIC 10.0 



3.1.1 INTRODUCTION 

This section lists BASIC 10.0 commands, statements, and functions in 
alphabetical order. It gives a complete list of the rules (syntax) of 
BASIC 10. 0, along with a concise description of each. 

3-1.1.1 QgM^TO_flND STAT^jENT_FORftRT 

The commands and statements presented in this section are governed 
by consistant format conventions designed to make them as clear as 
possible. In most cases, there are several actual examples to 
illustrate what the actual command looks like. The following example 
shows some of the format conventions that are used in the BASIC commands; 

7 

EXAMPLE : DLOAD <"program name"| (file name var)> [,U#] [/D#] 

i I II 

II It 

keyword - argument (if any) optional arguments 

The parts of the command or statement that the user must type in 
exactly as they appear are in capital letters. Words that don't have to 
be typed exactly, such as the name of the program, are not capitalized. 
When quote marks C" ") appear (usually around a program or file name) , 
the user should include them in the appropriate place according, to the 
format example. 



System Specification for C65 Fred Bowen March 1, 1991 

THFqp^i^v2SI;c^^SSoS^4^^ RESERVED WORDS, appear in uppercase letters. 
ITltl ^^P^^^S^^MOST BE ENTERED EXACTLY AS THEY APPEAR. However, many 
keywords have abbreviations that can also be used. 

Keywords are words that are part of the BASIC language that the 
computer understands. Keywords are the central part^f^l command o? 
statement. They tell the computer what kind of action to take ?hese 
words cannot be used as variable names. 

are J^e^^^J^i^ ""^^^^^ Parameters) appear in lower case. Arguments 
o^L^H^n^ P^'^?-.^^. ; command or statement; they complement keywords by 
ex^nfi^ !^^S '■'' i"^°^f^^°'' ^°"^ ^^^ command or statement. For 
tr^litr ^M^^u°'''^ ^^^^^ ^^^ computer to load a program, while the 
argument tells the computer which specific program to load and a second 
ArH^n^ ?P^?^5^«|. "^ich drive the disk containing the progrLi ?n 
Arguments include filenames, variables, line numbers, etc. 

^^ „^?,^^^^t^^^'^^ ^^ ^^o^ OPTlOUPd. a^rguments. The user selects any 
or none of the arguments listed, depending on the requirements. ^ 

argum^?f U^eS^''^ ^^ indicates that the user MUST choose one of the 

choicS^^a^ !tSiLr^?r^K' ^^^"^^ ^^ ^ H^^ °^ arguments when the 
na^ hf ne«5 ^ ft ^° ^^^^f arguments listed, and no other arguments 
bISckIt^ ;h.^^S ^^^ ^^^tical bar appears in a list enclosed in SQUARE 
h^^^^f'.^J^ choices are limited to the items in the list, but stiU 
have the option not to use any arguments. ^t-iix 

argum^S'cfn\e-;4ptalinS?| ?Lf SSL^°'^ ^^^^ an option or 

expressions''''' S' IrLSSn.'^"" chaiScter strings, filenames, and other 
I^^J^'-J?^- ^^t ^''^fents are enclosed in quotation marks in a 
5°f?^^: ^^^ ^°^J^i?^ "^^^^s ^^st be included in a coimnand file or 
il'^tff^^ly. Quotation marks are not, conventions used to describe 
formats; they are required parts of a command or statement. 

PARENTHESES {) When arguments are enclosed in parentheses in a 
format, they must be included in a command or statement Parentheses 

VARIABLE refers to any valid BASIC variable' name such as X, A$, or T%. 
EXPRESSION means any valid BASIC expression, such as A+B+2 or .5*{X+3). 



System Specification for C65 Fred Bowen March 1, 1991 

3.1.2 AlgHABETICai. I.IST OF CQMMflNPS, FQNCTIQNSr and OPEEtATORS 



(PI) 

ABS 

AND 
APPEND 

SC 
.1.TN 
AUTO 

BACKGROUND 
BACKUP 
BANK 
BEGIN 
BEND 
BLOAD 
BOOT 
BORDER 
BOX 
BSAVE 
BUMP 
B VERIFY 
CATALOG 
CHANGE 
CHAR 

CHR$ 7 
CIRCLE 
CLOSE 
CLR 
^MD 

-OLLECT 
JOLLISION 
COLOR 
CONCAT 
CONT 
COPY 
COS 
CUT 
DATA 
DCLEAR 
DCLOSE 
DEC 
DEF 

DELETE 
DIM 
DIR 
DISK 



Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 



AC 

AA 
AB 
AD 
B3 
B2 
Bl 
AE 



Token = FF 



Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
- Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 
Token 



B6 

AF 

FE, OE 

C6 

CI 

DC 

FE, 33 

F6 

FE, 02 

FE,18 

FE, 19 

FE,11 

FE,1B 

FE, 3C 

El 

FE, 10 

CE,03 

FE,28 

FE, OC 

FE,2C 

EG 

C7 

E2 

AO 

9C 

9D 

F3 

FE,17 

E7 

FE,13 

9A 

F4 

BE 

£4 

83 

FE, 15 

FE, OF 

Dl 

96 

F7 

86 

EE 

FE,40 



multiplication 
addition 
siibtraction 
division 
less -than 
equal 

greater- than 
exponentiation 

return value of PI 

absolute function 

logical AND operator 

append file 

string to PETSCII function 

trigometric arctangent function 

auto line numbering 

background color 

backup diskette 

memory bank selection 

start logical program block 

end logical program block 

binary load file from diskette 

load & run ML, or BASIC autoboot 

border color 

draw graphic box 

binary save to disk file 

sprite collision function 

verify memory to binary file 

disk directory 

edit program 

display characters on screen 

PETSCII to string finction 

draw graphic circle 

close channel or file 

clear BASIC variables, etc. 

set output channel 

validate diskette (chkdsk) 

enable BASIC event 

set screen colors 

concatenate two disk files 

continue BASIC program execution 

copy a disk file » 

trigometric cosine function 

cut graphic area 

pre-define BASIC program data 

mild reset of disk drive 

close disk channel or file 

decimal function 

define user function 

delete BASIC lines or disk file 

dimension BASIC array 

disk directory 

send disk special command 



System Specification for C65 



Fred Bowen 



March 1, 1991 



DLOAD 


Token = FO 


DMA 


Token = FE, IF 


DMA 


Token = FE,21 


DMA 


Token = FE,23 


DMODE 


Token = FE,35 


DO 


Token ^ EB 


DOPEN 


Token = FE, OD 


DPAT 


Token = FE,36 


DSAVE 


Token = EF 


DVERIFY 


Token - FE,14 


ELLIPSE 


Token = FE, 30 


ELSE 


Token = D5 


END 


Token - 80 


ENVELOPE 


Token = FE,OA 


ERASE 


Token == FE,2A 


ERR$ 


Token = D3 


EXIT 


Token = ED 


EXP 


Token - BD 


FAST 


Token = FE,25 


FILTER 


Token = FE, 03 


FIND 


Token = FE,2B 


FN 


Token ^ AS 


FOR 


Token - 81 


FOREGROUND 


Token = FE,39 


FRE 


Token - B8 


GCOPY 


Token = FE,32 


GENLOCK 


Token - FE,38 


GET 


Token = Al 


GO 


Token = CB 


GOSUB 


Token = 8D 


GOTO 


Token = 89 


GRAPHIC 


Token = DE 


HEADER 


Token = Fl 


HELP 


Token = EA 


HEXS 


Token " D2 


HIGHLIGHT 


Token ~ FE,3D 


IF 


Token = SB 


INPUT 


Token = 83 


INPUT* 


Token = 84 


INSTR 


Token = D4 


INT 


Token = B5 


JOY 


Token = CF 


KEY 


Token = F9 


LEFTS 


Token = C8 


LEN 


Token = C3 


LET 


Token =88 


LINE 


Token = E5 


LIST 


Token = 9B 


LOAD 


Token - 93 


LOCATE 


Token - E6 


LOG 


Token = BC 


LOOP 


Token = EC 


LPEN 


Token = CE^04 


MIDS 


Token ~ CA 


MONITOR 


Token = FA 


MOUSE 


Token = FE,3E 


MOVSPR 


Token = FE,06 


NEW 


Token = A2 



load BASIC program from disk 
define & execute DMA command 



set graphic draw mode 
start BASIC loop 
open channel to disk file 
set graphic draw pattern 
save BASIC program to disk 
verify BASIC memory to file 
draw graphic ellipse 
.if /then/else clause 
end of BASIC program 
define musical instrument 
delete disk file 
BASIC error function 
exit BASIC loop 
exponentiation function 
set system speed to maximtam 
set audio filter parameters 
hunt for string in BASIC program 
define user function 
start BASIC for/next loop 
set foreground color 
available memory function 
graphic copy 
set video sync mode 
receive a byte of input . 
program branch 
program subroutine call 
program branch 
set graphic mode 
format a diskette 
display BASIC line causing error 
return hexidecimal string function 
set highlight color 
if/then/else conditional 
recieve input data from keyboard 
.recieve input data from channel (file) 
locate a string within a string 
integer function 
joystick position function 
define or display f-unction key 
leftmost substring function 
length of string function 
variable assignment 
draw graphic line, input line 
list BASIC program 
load program from disk 

(currently unimplemented) 
natural log function 
end of do/loop 
lightpen position function 
substring function 
enter ML Monitor mode 
set mouse parameters 
set sprite position and speed 
clear BASIC program area 



System Speci 


fication for C65 


NEXT 


Token =82 


NOT 


Token * A8 


OFF 


Token = FE,24 


ON 


Token =* 91 


OPEN 


Token = 9F 


OR 


Token = BO 


PAINT 


Token = DF 


PALETTE 


Token = FE, 34 


PASTE 


Token ^ E3 


PEEK 


Token = 02 


PEN 


Token = FE,33 


PIC 


Token = FE, 37 


PLAY 


Token = FE, 04 



Fred Bowen 



March 1, 1991 



NEXT 


Token =82 


NOT 


Token * A8 


OFF 


Token = FE,24 


ON 


Token =* 91 


OPEN 


Token = 9F 


OR 


Token = BO 


PAINT 


Token = DF 


PALETTE 


Token = FE, 34 


PASTE 


Token ^ E3 


PEEK 


Token = C2 


PEN 


Token = FE,33 


PIC 


Token = FE, 37 


PLAY 


Token = FE, 04 


POINTER 


Token = CE, Oa 


POKE 


Token = 97 


POLYGON 


Token - FE, 2F 


")S 


Token = B9 


-OT 


Token = CE,02 


PRINT 


Token = 99 


PRINT# 


Token = 98 


PUDEF 


Token = DD 


QUIT 


Token - FE,1E 


RCLR 


Token = CD 


ROOT 


Token = DO 


READ 


Token = 87 


RECORD 


Token = FE,12 


REM 


Token = 8F 


RENAME 


Token = F5 


RENUMBER 


Token = F8 


RESTORE 


Token = 8C 


RESUME 


Token = D6 


RETURN 


Token = BE 


RGR 


Token = CC 


RIGHTS 


Token = C9 


RMOUSE r 


Token = FE, 3F 


RND 


Token = BB 


RREG 


Token = FE, 09 


RSP COLOR 


Token = CE, 07 


-•vSPPOS 


Token = CE^OS 


.SPRITE 


Token = CE,06 


RUN 


Token = 8A 


RWINDOW 


Token = CE, 09 


SAVE 


Token = 94 


SCALE 


Token ~ E9 


SCNCLR 


Token = E8 


SCRATCH 


Token = F2 


SCREEN 


Token - FE, 2E 


SET 


Token == FE, 2D 


SGN 


Token = B4 


SIN 


Token = BF 


ST.KEP 


Token = FE, OB 


SLOW 


Token = FE,26 


SOUND 


Token - DA 


SPC 


Token = A6 


SPRCOLOR 


Token - FE, 08 


SPRDEF 


Token = FE, ID 


SPRITE 


Token = FE,07 


SPRSAV 


Token = FE,16 



end of for-next loop 

logical complement function 
(subcommand) 

multiple branch or subcommand 

open I/O channel 

logical or function 

graphic flood-fill 

set palette color 

draw graphic area from cut buffer 

return memory byte function 

set graphic pen color 

graphic subcommand 

play musical notes from string 

address of string var function 

change memory byte 

draw graphic pologon 

text cursor position function 

return paddle position 

display data on text screen 
send data to channel- (file) 
define print-using symbols 

{currently unimplemented) 
(currently unimplemented) 
(currently unimplemented) 
read program pre-defined program data 
set Relative disk file record pointer 
BASIC program comment 
rename disk file 
renumber BASIC program lines 
set DATA" pointer, subcommand 
resume BASIC program after trap 
end of subroutine call 

(currently unimplemented) 
rightmost substring function 
read mouse position 
pseudo random number function 
return processor registers after SYS 
return sprite color function 
return sprite position function 
return sprite parameter function 
run BASIC program from memory or disk 
return text window parameter function 
save BASIC program to disk 

(currently unimplemented) 
erase text or graphic display 
delete disk file 

set parameters or open graphic screen 
set system parameter, subcommand 
return sign of number function 
trigometric. sine function 
pause BASIC program for time period 
set system speed to minimum 
perform sound effects 
skip spaces in printed output 
set multicolor sprite colors 

(currently unimplemented) 
set sprite parameters 
set or copy sprite definition 



System Specification for C65 



Fred Bowen 



March 1, 1991 



SQR 


Token 


=s 


BA 


STEP 


Token 


= 


A9 


STOP 


Token 


= 


90 


STR$ 


Token 


ss 


C4 


SYS 


Token 


= 


9E 


TAB( 


Token 


= 


A3 


TAN 


Token 


ss 


CO 


TEMPO 


Token 


= 


FE,05 


THEN 


Token 


= 


A7 


TO 


Token 


= 


A4 


TRAP 


Token 


s= 


D7 


TROFF 


Token 


ss 


D9 


TRON 


Token 


= 


D8 


TYPE 


Token 


= 


FE,27 


ONTIL 


Token 


= 


FC 


USING 


Token 


ss 


FB 


USR 


Token 


= 


B7 


VAL 


Token 


ss 


C5 


VERIFY 


Token 


ss 


95 


VIEWPORT 


Token 


ss 


FE,31 


VOL 


Token 


ss 


DB 


WAIT 


Token 


= 


92 


WHIT.F, 


Token 


s 


FD 


WIDTH 


Token 


= 


FE, IC 


WINDOW 


Token 


= 


FE,1A 


XOR 


Token 


= 


CE,08 



square root function 

for-next step increment 

halt BASIC program 

string representation of number function 

call ML routine 

tab position in printed output 

trigometric tangent function 

set tempo (speed) of music. play 

if/then/else clause 

(sxibcommand) 
define BASIC error handler 
BASIC trace mode disable 
BASIC trace mode enable 
display sequential disk file 
do/loop conditional 
define print output format 
call user ML function, 
numeric value of a string function 
compare memory to disk file 

(currently unimplemented) 
set audio volume 

pause program pending memory condition 
do/loop contitional 

(currently unimplemented) 
set text screen display window 
logical xor function 



■v>.- 



System Specification for C65 Fred Bowen. March 1, 1991 

3,1.3 BASIC 10.0 COMMRND AND FONCTION DESCRIPTION 

ABS - Absolute value function 

ABS (expression) 

The ABSoiute value function returns the unsigned value of the numeric 
expression. 

X = ABS(l) Result is X ==1 

X = ABS(-l) Result is X = 1 

AND - Boolean operator 

expression AND expression 

The AND operator returns a numeric value equal to the logical AND of 
two numeric expressions, operating on the binary value of signed 
16-bit integers in the range (-32768 to 32767). Numbers outside this 
range result in an 'ILLEGAL QUANTITX' error. 

X = 4 AND 12 Result is X=4 

X = 8 AND 12 Result is X=8 

X = 2 AND 12 Result is X=0 

In the case of logical comparisons, the numeric value of a true 
situation is -1 (equivalent to 65535 or $FFFF hex) and the numeric 
value of a false situation is zero. 

-^ •• 

X = ("ABC"="ABC") AND ("DEF"="DEF") Result is X=-l (true) 
X = ("ABC"-"ABC") AND ("DEF"="XYZ") Result is X= (false) 

APPEND - Open a disk file and prepare to append data to it 

APPENDS logical_file_number, "filename" CDdrive] [<0N| ,>Udevice] 

Opens filename for writing, and positions the file pointer at the end 
of the file- Subsequent PRINT* statements to the logical_file__number 
will cause data to be appended to the end of this file. If the file 
does not exist, it will be. created. 

APPEND#1, "filename" 
APPEND#1, (fileS), ONO(unit) 

ASC — PETSCII value function 

ASC (string) 

This function returns the PETSCII numeric value of the first character 
of a string. The PETSCII value of an empty (null) string is zero. 
This function is the opposite of the CHR$ function. Refer to the 
Table of PETSCII Character Codes. 

X = ASC ("ABC") Result is X=65 

X = ASC{"") Result is X-0 

ATK - Arc tangent fxinction 

ATN (expression) 



This function returns the angle whose tangent is the value of the 

X == ATN(45) Result is X'^l. 54050257 

To get the arc tangent of an angle measured in degree's, multiply the- 
numerxc expression by pi/180. j-uj-pxy une 

AUTO - Enable or disable automatic line numbering 

AUTO [increment] 

Turns on the automatic line numbering feature which eases the iob of 
entering programs by typing the line numbers for the user. As each 
S^?2?f2 ^'■"Ju'-^ entered by pressing RETURN the next line number is 
^fi^*'^'^™^^ ^ =^«;"' «ith the cursor in position to begin typing that 
ni^h;.. mtSS''^'^!?^ parameter refers to the increment between line 
aS?^ mnH. tr^/^'^^ '''' increment given turns off auto line numbering. 
AUTO mode is also turned off automatically when a program is RUN This 
statement is executable only in direct mode. . ^ "^^ ^^ ^""' "^^^^ 

tuln In ^^5°"^atically numbers line in increments of ten. 
aJJJS automatically numbers line in increments of fifty. 
AUTO turns off automatic line numbering. 



BACKGROUND - Set the background color of the display 

BACKGROUND color ' 

Sets the screen background color to the given color. The color 
given must be m the range (>15) . See the Color T^bleV 

BACKUP - Backup an entire disk from one drive to another 

BACKUP Dsource_drive TO Ddestination_drive [<ONi ,>Udevice] 

SiL"'^!;;^;^^ "?^^^ ?^^ ^^^ ^^^^^ °" ^ diskette to another on a dual 
tZtZ^tr T^^- ^t^^^^'^ot backup diskettes using CBM serial bus 

bK?K0^ wTTf'..5?n ^^^"^W J-^ the destination diskette is unformatted, 
BACKUP will automatically format it. BACKUP copies every sector so 
any data already on the destination diskette will be overwritten' ?o 
copy specific files from one drive to another, use IhelpPY co^nd 

fS^^4J?^^4^°?!?fSv S^^ only be used with a dual disk drive, such as 
the buiit-in C64DX drive and optional F016-type expansion drive To 

anf a'^lfsf^^^r.o?^''? ^^^^^^"^ '^"'^^^' ^^^^^= *^^« built-fn dkve 
and a 1581-type serial bus drive, use a utility program. 

BACKUP DO to Dl Copies all files from the disk in 

drive to the disk in drive 1. 

BACKUP DO TO Dl, ON U9 Copies all files from drive to 

drive 1 in disk drive unit 9, 

BANK - Set the memory bank number for PEEK*POKE,SYS,WAIT,LOAD,SAVE 

BANK memory_bank 
[*** THIS COMMAND MIGHT CHANGE ***] 



This command should be used before and BASIC command that has an 
address parameter. The address paraiaeters are limited to the range 
(0-65535, SOOOO-$FFFF hex) , The BANK command tells the computer 
which 64K byte memory bank the location you want is in. 

The memory_ban]c parameter is number from 0-255. Refer to the System 
memory map to see what is in each bank. A BANK number greater than 
127 (i.e., has its most significant bit set) means "use the current 
system configuration", and must be used to access an I/O location. 
BASIC defaults to BANK 128. 

For examples, see PEEK, POKE, etc. 

BEGIN/BEND - Extend an TF clause over more tihan one line 

BEGIN/BEND are used to define a block of code which is considered 
by the IF statement to be one statement. 

The normal usage of IF/THEN/ELSE would be along the following lines: 

IF boolean THEN statement (s) : ELSE statement (s) 

The main restriction is that the entire body of the IF/THEN/ELSE 
construct can only occupy one line. BEGIN /BEND allows either the 
'THEN' or the 'ELSE' clause to run on for more than one line. 



IF boolean THEN BEGIN : statements. - 

statements. , 
statements . , 
statements . . 
statements. . 



BEND : ELSE BEGIN 
BEND 



Remember, however, that this is only a way to extend the body for 
more than one line: all other ' IF /THEN' rules apply. For example; 

7 100 IF x=l THEN BEGIN : a=5 

110 : b=6 
120 : c-7 
130 BEND : print "ah-ha!" 

In the above example, "ah-ha!" would be printed ONLY if the expression 
expression 'x=l' is TRUE, because the print statement is on the same 
logical line as the THEN clause. 

It is bad practice to GOTO a line in the middle of a BEGIN-BEND block. 
If BEGIN or BEND is encountered outside of an active IF* statement, it 
is ignored. 

BLOAD - loads a binary disk file Into memory 

BLOAD "filename" [,Bbarikl [,Paddress] [<0N1 ,>Udevicel 

Used to load a machine language program or other binary data (such 
as display pictures or sprite data) into memory. If a load address is 
not given, the load address given in the disk file will be used. If a 
bank number is not given, the bank given in the last BANK statement 
will be used. If a load overflows a bank (that is, the load address 
exceeds 65535 ($FFFF) , an 'OUT OF MEMORY' error is reported. 
Also see the LOAD command. 

BLOAD "sprites", P (dec("600") ) , BO 
BOOT - Load and execute a program 



BOOT 

BOOT SYS 

BOOT filename [,Bbank] [,Paddressj [^Ddrive] [<0N1 ,>Udevice] 

BOOT without a filename given causes the computer to look for a BASIC 
program called AUT0B00T.C6S* on the indicated diskette, LOAD it and 
RUN it (just like RUN "AUTOBO0t.C65*") . 

BOOT with a filename given will cause the executable binary file to be 
BLOADed and executed beginning at the load address. If a load address 
is not given, the file will be loaded and execution begun, at the 
address stored on disk. 

BOOT SYS is a special command that copies the "home" sector (the very 
track and sector) of the C64DX built-in drive into memory at address 
$400 to $5FF (one physical sector, 512 bytes) and perform a machine 
language JSR (Jump SubRoutine) to it. It has the same function as 
turning on your C64DX while holding down the ALT key. It is used to 
boot an alternate operating system from either a CBM 3.5" diskette or 
an MSDOS (720K) diskette. If used in a BASIC program, and it fails, 
the system can be corrupted. BOOT SYS does *not* use the normal DOS 
to access the disk. 

BOOT Loads & runs BASIC program called 

AUTOB0OT.C65* on system disk. 

BOOT U9 Loads & runs BASIC program called 
AUTOBOOT.C65* on disk unit 9. 

BOOT "ml- Load & executes machine language 

program called ML, starting at address 
stored on disk. 

BORDER - Set the exterior border color of the display 

BORDER color 

Sets the screen border color to given color. The color must be in 
the range (0-15) . See the Color Table. 

BOX - Draw a 4-sided graphical shape 

BOX xO,yO, xl,yO, xO,yl, xl,yl [, solid] 

Requires two line segments to be specified, the order of which 
determines the shape drawn. The shape is drawn in the currently 
specified PEN color, on the currently specified SCREEN. The above 
command will draw the following shape: 



0,<0 



0,<1 



luso 



ll,<l 



But if the order of the coordinates were given as: 

BOX xO,yO, xl,yO, xl,yl^ xCyl 
a "bowtie" shape would be drawn. See the sample program at SCREEN 

BSAVE - Save an area of memory in binary disk file 



BSAVE "[@] filename" r Pstart_adr TO Pend_adr [,Bbank] [,Ddrive] [<0N| ,>Udevice] 

BSAVE copies an area of memory into a binary disk file called 
"filename", starting at start_adr and ending at end_adr-l (i.e., 
end_adr must be one more than actual last address saved) . If a bank 
number is not given, the bank given in the last. BANK statement will 
be used. End_adr must be greater than start_adr, and area to be saved 
must be limited to the indicated memory bank. You cannot save data 
from more than one bank at a time. Start^adr is saved on disk as the 
load address. If filename already exists"on the designated diskette, 
memory is NOT saved and a 'FILE EXITS' error is reported. Preceding 
the filename with an '@'-sign will allow you to overwrite an existing 
file, but see the cautions at DSAV^. 

BSAVE "sprites", P (decC"600") ) TO P(dec("800") ) , BO 

BDMP - Sprite collision function 

BUMP (type) 

This function return a numeric summary of sprite- collisions 
accumulated since the last time the BtJMP. function was used. 

You can use the COLLISION command to set up a special routine in 
your program to receive control whenever a sprite BUMPs into 
something, but a particular COLLISION does not have to be enabled 
to use BUMP. See the COLLISION command. 

To evaluate sprite collisions, where a BIT position (0-7) in the 
numeric result corresponds to a sprite number (0-7) : 



BIT position: 

BUMP value in binary: 



76543210 

I i i I I I I i 
00000101 



= 5 decimal 



BUMP(l) returns a value representing sprite-to-sprite collisions. 
BUMP (2) returns a value representing sprite-to-dat a collisions. 



X = BUMP(l) 



Result is X=3 if sprites & 1 collided, 
as shown above, (binary 101 = 5 decimal) 



Note that more than one collision can be recorded, in which case you 
should evaluate a sprite's- position using the RSPPOS function to 
figure out which sprite collided with what. BUMP is reset to zero 
after each use. ' , 



BVERIFY - Compare a binary disk file to an area of memory 

BVERIFY "filename" [,Paddress] [,Bbank] [,Ddrive ] [<0N| ,>Udevice] 

BVERIFY compares a binary disk file called "filename" to an 
area of memory. In direct mode, if the areas contain the same data 
the message "OK" is displayed, and if the data differs the message 
'VERIFY ERROR' is displayed. 

In program mode, an error is generated if a mismatch is found, 
otherwise the program continues normally. The comparison starts with 
the address given, else it starts at the address stored on disk. 
The comparison ends when the last byte is read from the disk file. 

If a bank number is not given, the bank given in the last BANK 
statement will be used. The ending address is determined by the 
length of the disk file. The comparison halts on the first mismatch 



or at the end of the file. The area to be compared must be confined 
to the indicated memory bank. 

BVERIFY "sprites", P (dec ("600") ) , BO 
C&TAWG - see DIR (DIFECTORY) connnand 

CHANGE - Find text in a BASIC program and change it. 

CHANGE istringl: TO :string2: [,line range] ■ 
CHANGE "stringl" TO "string2" [,line_rangel 

This is a direct (edit) mode command. CHANGE looks for all occurances 
of stringl in the program, displays each line containing stringl with 
the target string highlighted, and prompts the user for one of the 
following: 

Y<return> Yes, change it and look for more 

N<return> No, don't change it, but look for more 

*<return> Yes, change all occurances from here on 

<return> Exit command now, don't change anything 

Any character can be used for the string delimiter, but there are 
side effects: see comments at FIND command. If the line number range 
is not given (see LIST for description of range parameter), the entire 
program is searched. 

CHAR - Draw a character string on a graphic screen 

CHAR column, row, height, "width, direction, "string" [,charsetadr] 

[*** THIS IS Subject to change ***] 

CHAR displays text on a graphic screen at a given location. The 
character height, width, and direction are programmable. The 
parameters are defined as: 

column: Character position: 

For 320 wide screens, 0-39 
For 64 wide screens, 0-7 9 
row: Pixel line: 

For 200 line screens, 0-199 

For 400 line screens, 0-399 

height: Multiple of 8-bit character height: 

1= 8 pixels high, 2- 16 pixels, etc. 
width: Multiple of 8-bit character width: 

1= 8 pixels high, 2= 16 pixels, etc. 
direction: Bit mask: B0= up 

Bl= right 
B2= down 
B3= left 

The string can consist of any printable character, as defined by the 
VIC character set. Non-text characters are ignored. If the address 
if the character set is not given, the upper/lower ROM character set 
is used ($29800) . 

CHAR 18,96, 1,1,2, "C64D", DEC ("9000") 

The above example will draw the characters "C65D" in the center of a 
320x200 pixel screen using the system's uppercase/graphic character set 



CHR$ — Character string function 

CHR$ (value) 

This function returns a string of one character having the PETSCII 
value specified. This function is the opposite of the ASC function. 
It's often used in PRINT strings to output data that is not visible, 
such as control codes and escape sequences , Refer to the Table of 
PETSCII Character Codes. 

PRINT CHR$(27)"Q"; CHR$ (27) is the escape character. 

This statement performs the 
clear-to-end-o£-line escape function. 

CIRCLE — Draw a circle on a graphic screen 

CIRCLE x^center, y^center, radius [, solid] 

The CIRCLE command will draw a circle with "the given radius centered 
at (x_center,y_center) on the current graphic screen. The circle will 
be filled (i.e., a disc) if SOLID is non-zero. 

CIRCLE 160,100,50 

The above example will draw a circle in the center of a 320x200 pixel 
screen (160,100) having a radius of 50 pixels. The aspect ratio of the 
screen may cause it to appear as an ellipse, however. See also the 
ELLIPSE command. 

CLOSE - Close a logical I/O channel 

CLOSE ■ logical__channel_number 

This command closes the input/output channel associated with the 
cVen logical channel_number, established by an OPEN statement. 
In the case of buffered output (such as the serial bus or RS232) any 
data in the device's buffer will be transmitted before the channel is 
closed. Refer to specific I/O operations for details. 

The logical_channel number is required; to close all channels on a 
given device, use tHe DCLOSE command. Note that RUN, NEW, and CLR 
commands will initialize the logical channel tables but will not 
actually close any channels. 

CLR - Clear program variables * 

CLR 

This statement initializes BASIC'S variable list, setting all numeric 
variables to zero and string variables to null. It also initializes 
the DATA pointer, BASIC runtime stack pointer (i.e., clears all GOSUBs, 
DO/LOOPs, FOR/NEXT loops, etc.), and clears any user functions 
(DEF FNx) . Any OPEN" channels are forgotten (but a CLOSE is not 
performed- don't use if there are any open disk output files) . 
A CLeaR is automatically performed by a RUN or a NEW command. 

CMD - Set default output channel 

CMD logical_channel_number [, string] 

CMD changes the default output device, normally the screen, to that 
specified. The logical_channel_number can be any previously OPENed 



write channel, such as one to a disk file, printer, or RS232* 

When redirected via CMD, all output which normally would go to the 
screen (such as PRINT commands, LIST output, DIRECTORY lists, etc.) 
is sent to another device or file. 

The redirection is terminated by CLOSE-ing the CMD channel or executing 
a PRINT* to the CMD channel. Some output devices require a PRINT# to 
be performed before the CMD channel is closed, such as printers, to 
cause the device's buffer to be flushed (i.e., displayed). 

Any system error will redirect output back to the system default, 
normally the screen, but will not flush nor close the output channel. 

If the optional string is given, it is output immediately after the 
CMD device is established. This feature is normally used to set up 
printers (eg., set printer modes via escape codes) or to identify 
the output (eg., title printouts). 

OPEN 4,4 OPENS device #4, which is the printer. 

CMD 4 All normal output now goes to the printer. 

LIST The LISTing goes to the printer. 

PRINT* 4 Set output back to the screen. 

CLOSE 4 Close the printer channel. 

COLI£CT - Check (validate) disk, delete bad files and free lost sectors 

COLLECT [Ddrive] [<0N! , >adevice3 

Refer to the DOS 'Validate command. This command will cause the DOS 
to recalculate the Block Availability Bam (BAM) of the diskette in the 
indicated drive, allocatrng- only those sectors being used by valid, 
properly closed files. Ail other sectors are marked as "free" and 
improper files are automaticAly deleted. 

Note: COLLECT should be used with extreme care, and MaST NOT be used 
on diskettes with special boot sectors or direct access (eg., random) 
files. In any case, be sure the diskette has been BACKUP-ed first. 

COItLISION - Setup subroutine to handle special events 

COLLISION type [,linenmciber] 
[*** THIS MIGHT CHANGE ***] 

COLLISION is used to handle "interrupt" situations in BASIC, such as 
sprites bumping into things or lightpen triggers. When the specified 
situation occurs, BASIC will finish processing the currently executing 
instruction and perform an automatic GOSUB to the iinenumber given. 

When the subroutine terminates (it must end with a RETURN) BASIC will 
resume processing where it left off. Interrupt handling continues 
until a COLLISION of the same type but without any Iinenumber is 
specified. More than one type interrupt may be enabled at the same 
time, but only one interrupt can be handled at a time (i.e., no 
recursion and no nesting of interrupts) . The type interrupt can be: 

1 = Sprite to sprite collision 

2 = Sprite to display data collision 

3 = Light pen 

Note that what caused an interrupt may continue causing interrupts 
for some time unless the situation is altered or the interrupt is 
disabled. This is especially true for BASIC, which is slow to 



respond to interrupts. Use the BUMP and RSPPOS functions to evaluate, 
the results of sprite collisions, and the LPEN fxinction to evaluate 
the position of a light pen. 

10 COLLISION. 1,90 

20 SPRITE1,1:MOVSPR1,100,100:MOVSPR1,0#5 

30 SPRITE2,1:MOVSPR2,100,150:MOVSPR2,180#5 

40 DO: PRINT: LOOP 

50 END 

90 PRINT"BOMP! ";:RETURN 

In this example, sprite-to-sprite collisions are enabled (line 10) , 
and two sprites are turned on, positioned, and made to move {lines 
20 & 30) . One sprite moves up and the other moves down while the 
program does nothing other than print blank lines to the screen (line 
40). When the sprite collide, the subroutine at line 90 is called, 
it prints "BUMP!", and the computer goes back to printing blank lines. 

COLOR - Enable or disable screen color (character attribute) control 

COLOR <0N I OFF> 

COLOR turns on or turns off the screen editor's attribute handler. 
When colors are turned off, whatever character attributes are being 
currently displayed (text color, underline, flash, etc.) are "stuck". 
The mam purpose for doing this is to speed up screen handling 
(writing to the screen or scrolling the screen) about two times, 
sxnce the screen editor no longer has to manipulate the attibutes. 
Note that only FOREGROUND colors (and special VIC attributes) are 
affected. 

To change screen colors, jasjs the following commands: 

FOREGROUND color* Set Foreground color (text) 

HIGHLIGHT color* Set Highlight color (text) 

, BACKGROUND color* Set VIC Background color 

BORDER color* Set VIC Border color 

CONCAT - Concatenate (merge) two sequential disk files 

CONCAT "filel"[,Ddrivel] TO "file2" [,Ddrive2J [<ONr,>Udevice] 

CONCAT merges two SEQuential files, appending the contents of 

i^Z^K to "file2". Upon completion, "file2" contains the data 
of both files, and "filel" is unchanged. Both files mugt exist on 
dra-ves of the the same unit, and pattern matching is not allowed. 

Some disk drives handle CONCAT differently; refer to the DOS manual 
for specific details. 

CONT - Continue program execution 

CONT 

CONTinue is used to re-start a BASIC program that was halted 
by a STOP or END statement, or interrupted by the STOP key. The 
program will resume at the statement following the STOP or END 
instruction, or at the statement after the one thaf was interrupted 
by the STOP key. CONT is typically used during program debugging. 
Vou can look at and alter variables while the program is halted. 

Programs halted as a result of an untrapped error condition cannot 
be CONTinued. Programs that have been edited in any way cannot 



restarted. Any error condition that occurs since the program 
was halted will prevent it from being restarted. Programs that 
cannot be restarted via CONT can be restarted with a GOTO, as long 
as you don't need to resume execution in the middle of a line of 
commands and you recall where the halt occurred. 

Note that the STOP key can interrupt some commands in mid-execution, 
such as file I/O, drawing commands, etc. In such cases, programs 
may not run correctly after a CONTinue. 

COPY - Copy disk files 

COPY ["filel"]C,Ddl] TO ["file2"] [, Dd2J [<bN| ,>Udevice] 

COPYs a disk file to another disk file. On single drive units, the 
filenames must be different. On dual drive units, copying can be 
done between two drives on the same unit, and the filenames can be 
the same or different. Pattern matching an be used.. Copying files 
from one unit to a different unit cannot be done; use a copy utility 
program in such cases. Only legal type files can be copied; direct 
access data, boot sectors, and partitions cannot be copied. 

Refer to the DOS manual for your disk drive for specific details. 

COPY "filel- TO (f2$) - copies "filel" to another file 

whose name is in F2$ on the 

rnov "^'i in rvft m« r.-, „^ ^^^^ drlve . Names must differ. 
COPY "filel'',DO TO D1,U9 Copies "filel" from unit 9 

COPY "7.7.sr=",D<rTO -..-,01 ^^t^ liles%^^k;j2io " 

matching the pattern to a file 
of the same name on drive-1 . 

COS - Cosine function 

COS (expression) 

This function returns the cosine of X, where X is an angle measured 
m radians. The result is in the range -1 to 1. 

X ^ COS<pi> Result is X=-l 

expHLio^ bTpT/lll."' ^"^'' -«--«<i in degrees, muXt-iply the numeric 

CUT - Cut a graphic area into a temporary structure 

CUT x,y,dx,dy 
[*** NOT YET IMPLEMENTED ***] 

DATA " Define program constant data to be accessed by READ command 

DATA [list of constants] 

DATA statements store lists of data that will be accessed during 
program execution by a READ statement. The DATA statement can appear 
anywhere m the program, and it is never executed, BASIC keeps a 
pointer to the earliest un-READ DATA statement, and data is read 
sequentially from first item in a DATA statement to the last item. 



from the earliest DATA statement in the program to- the last DATA 
statement in the program. 

The list of constants can contain both numeric data (integer or 
floating point) and string data, but cannot contain expressions which 
must be evaluated (such as 1+2, DECC"1234"), or CHR$(13)). items are 
separated by commas. String data need not be enclosed in" quotes unless 
it contains certain characters, such as spaces, commas, colons, graphic 
characters, or control codes. If two commands have nothing between 
them, the data will be READ as if numeric or a null string. 

The RESTOEIE command allows you to position BASIC'S data pointer to a 
specific line number. If the program tries to read more DATA than 
exists in the program, an 'OUT OF DATA' error results. If a READ 
statement' s variable type does not agree with the DATA being read, a 
'TYPE MISMATCH' error results. 

DATA 100, 200, FRED, "HELLO, MOM", , 3.14, ABC123, -1 . 7E-9 

DCliElAR - Clear all open channels on disk drive 

DCLEAR [Ddrive] [<0N| , >Udevicel 

DCLEAR sends the indicated disk drive an 'I'nitialize command. This 
clears all open channels, closes all open files, and causes the DOS to 
re-read the diskette's Block Allocation MAP (BAM). Note that DCLEAR 
DOES NOT close open channels on the computer's side (see the DCLOSE 
command) . There are some other side affects caused by this command 
with different types of drives- refer the DOS manual for your disk 
drive for specific details* 

DCLOSE - Close a disk file, or close all channels on a device 

DCLOSE [#logical_file_number] t<ON! ,>Udevice] 
? 
DCLOSE is intended to close a file opened with the DOPEN command. 
Specific files can be closed by specifying a logical_file number, 
or all files on a particular drive can be closed by not specifying 
a particular logical_file nxamber. 

It is possible to close channels on non-disk devices with this 
command by specifying only the device number. 

DCLOSEfl Closes the file associated with logical 
logical file number 1. • 

DCLOSE Closes all files currently open on the 
default system drive. 

DCLOSE U(U2) Closes all channels open to device U2. 

DEC - Decimal value function 

DEC (hex_string) 

This function return the decimal value of a string representing a 
hexadecimal number in the range "0000" to "FFFF". The result is in 
the range 0-65535. . If the string contains a n on -hexadecimal digit 
or is more than four (4) characters in length an 'ILLEGAL QUANTITY' 
error is reported. 

VIC = DEC("D000") Result is VIC='53248, 

the address of the VIC chip 



DEF FN - Define function 

DEF FNname (rnimeric__variabie) = numeric_expression 

Define a user-written numeric function. The DEF FNx statement must 
be executed before the function can be used. Once a function has 
been defined, it can be used like any other numeric variable. The 
function name is the letters FN followed by any legal floating point 
(non-integer) variable name. A function can be defined only in a 
program. "^ 

The nuraeric_variable is a "dummy" variable. It names the -variable in 
the numeric_expression which will be replaced when the function is 
used. It's not required to be used in the numeric expression, and 
its value won't be changed by the function call. " 

The numeric expression performs the calculations of the function. It 
IS any legal numeric expression that fits on one line. Variables used 
in the expression have their value at the time the function is used. 

Functions can be used only by the program which defines them. If 
one program chains to another program, the first program's functions 
cannot be used (usually a 'SYNTAX ERROR' results). Similarly, if 
the program is moved in any way after the function is defined, the 
function cannot be used. 

10 DEF FNR(MAX) => INT (RND (0) *MAX) +1 
20 INPUT "MAXIMUM"; MAX 
30 PRINT FNR(MAX) 

In this example, we've defined a function which will return a pseudo 
random number between 1 and whatever MAX is. Instead of usino the 
expression INT(RND(0) *MAX1 +1 every time a random number is needed, we 
can now use FNR(MAX) , When we use FNR(x), the value of 'x' will be 
be substituted everywhere MAi^f is used in the function definition. 

10 DEF FNICX) = X+1 

20 DEF FNL(Z) =-LEN(A$) 

30 DEF FNAVG(N) = (T0T*CNT+N) / (CNT-»-l) 

DELETE - Delete lines of BASIC program, oi: 
Delete disk files 

DELETE Estartline) [-[endlinej] 

DELETE "filespec" C/Ddrive] t<ON| , >Udevice] [,R] 

« 

There are two forms of DELETE. The first form is used in direct mode 

to remove lines from a BASIC program: 

DELETE 75 Deletes line 75. 

S^J^IS ^°.: ^° Deletes line 10 through 50 inclusive. 
DELETE - 30 Deletes all lines from the beginning of 
r>=.Tr.^,. nc ^^® program up to and including line 50, 
DELETE 75- Deletes all lines from 75 to the end of 

the program. 

The second form is used in program or direct mode to delete a disk 
file. See the SCRATCH command. 

DELETE "myfile" Deletes the file MYFILE on the system drive. 

DIM - Declare array dimensions 

DIM variable (subscripts) [, variable (subscripts) ] . . . 



Before arrays of variables can be used, the program must first 
execute a DIM statement to establish DIMensions of that 
array (unless there are 11 or fewer elements in the array) , 
The statement DIM is followed by the name of the array, which 
may be any legal variable name. Then, enclosed in parentheses, 
put the number (or numeric variable) of elements in each 
dimension. An array with more than one dimension is- called a 
matrix. Any number of dimensions may be used, but keep. in mind 
that the whole list of variables being created takes up space 
in memory, and it is easy to run out of memory if too many are 
used. To figure the number of variables created with each DIM, 
multiply the total number of elements in each dimension of the 
array. Note: each array starts with element 0, and integer arrays 
take up 2/5ths of the space of floating point arrays. 

More than one array can be dimensioned in a DIM statement by 
separating the arrays by commas. If the program executes a DIM 
statement for any array more than once, the message 'REDIM'D ARRAY' 
is reported. It is good programming practice to place DIM statements 
near the beginning of the program. 

10 DIM A$(40),B7(15),CC%(4,4,4) 

I i I 

41 elements 16 elements 125 elements 



DIR 
DIRECTORY 



- List the files of a diskette 



DIRECTORY ["filespec"] [,R] [,Ddrive] [<ONi ,>Udevice] 

A directory is a list of ihfi names of the files that are on a diskette, 
The directory listing consists of the name of the diskette, the names, 
sizes, and filetypes of all the files on a diskette, and the remaining 
free space on the diskette. The filespec is used to specify a pattern 
m^tch string to view selected files. Not all disk drives support 
tne same options or filespecs; refer to your DOS manual for details. 
The C64DX allows you to print DIR listings without having to 'load' 
the directory; see example below. 

The commands DIR, DIRECTORY, and CATALOG have the exact same function. 
They can be used in direct or program mode. 



DIRECTORY 

DIR "*,src", U9 

DIR "*,=p",R 

0PEN4 , 4 : CMD4 : D IR : CL0SE4 



List all files on the diskette 

in the default system drive. 

Lists the all the files ending with 

".src" on unit 9. * 

List all the deleted but recoverable 

PRG-type files on the system drive. 

Print DIR listing to printer unit 4 . 



The following program can be used to load the directory into variables 
for use within a program. In this case, the filensune is simply printed 
to the screen: 



10 OPEN 1,8,0,"$0:*,P,R" 

20 : IF DS THEN PRINT DS$ : GOTOIOO 

30 GET#1,X$,X$ 

40 DO 

50 : GET#1,X$,X$: IF ST THEN EXIT 

60 : GET#1,BL$,BH$ 

70 : LINE INPUT#1, F$ 

80. : PRINT LEFT$(F$,18) 

90 : LOOP 



open dir as a file 

abort if error 

trash load address 

read each line 

trash links, check eof 

get file size 

get filename fi type 

print filename 

loop until eof 



100 CLOSE 1 Close dir 

DISK - Send a disk command 

DISK "conimand_string" [<0N! , >Udevice] 

nSS ^?^^ command is used to send special commands to" the 

DOS via the disk drive's command channel. The DISK command is 

analogous to the following BASIC code: 

OPEN l,n,15: PRINTfl, "command_string": CLOSE 1 

Not all disk drives understand the same commands'. Refer to your 
DOS manual for commands and command syntax for your drive. Note 
that the drive number, if any, must be included in the command_string. 

Srf^ «H2^^°" Renumber system drive to 10. ■ 

DISK "UO>V"+chr$ (0) Turn off write verify 
DISK "SO:file" ,U(n) Scratch "file" on unit n 

DLOAD - Load a BASIC program file from disk 

DLOAD "filename" [,Ddrive] [<0N| ,>Udevice] 

This command copies a BASIC program from disk into the BASIC program 
area of the computer. It can then be edited, DSAVEd, or RUN. 

Used in program mode, it overlays the current program in memory and 

VariahTrSSltn-^^''^°''^^l?^i^^.^^ ^^^ ^^^^^ ^^"^ °^ the new program, 
^hf H^iv ^^^^"^tions will be left intact, but any open data files and 
CHAINING. channel ^lil be automatically closed. This is called 

See also RUN. Use BLOAD to load binary or machine language data. 

DLOAD "myprogram" Searches the default system disk drive 

for the BASIC program "myprogram", 

„^-^ ,^^, „^ loads it, and relinks it. 

DLOAD (F5),U9 LOADs a program whose name is in F$ 

from disk unit 9. 

DMA - Perform a DMA operation 

DMA command [/length, source (1/h/b) ,dest (l/h/b) ,subcmd,mod{l/h) [,...]] 
[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

The DMA command defines and executes a Direct Memory Access operation 

hn^S^^'^r^" "^ "^5^ ^° construct a DMA list, which is then passed 
to the DMA processor for execution. Refer to the DMA chip 

SfJri^t^^^^°"n5?'' 'details. Chained DMA commands are not allowed, 
but multiple DMA commands can be given and the DMA handler will set up 
and execute each one, one at a time. Refer to the system memory map 
to find out where things are. ^ f 

Because this command directly accesses system memory, extreme care 
should be taken in its use. Changing the wrong memory locations can 
crash the computer (press the reset button to reboot) . 

DMA 3, 2000, ASC("+"),0, ' DECC"800"),0 . Fill screen with '+' 
DMA 0, 2000, DEC("800-),0, DECC"8000'M , 1 Copy screen to 518^00 



« 



DMODE - Set graphic display mode 

DMODE jam, comp, inverse, stencil, style, thickness 

[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

jam 0-1 

complement 0-1 

inverse 0-1 

stencil 0-1 , 

style 0-3 

thickness 1-8 

DO/LOOP /HHII£/UNTIL/EXIT - Program loop definition and control 

DO [UNTIL boolean_expression 1 WHILE boolean_expression] 

■ 

statements [EXIT] 

LOOP [UNTIL hoolean_expression | WHILE boolean_expression] 

Performs the statements between the DO statement and the LOOP 
statement. If no UNTIL or WHILE modifies either the DO or the LOOP 
statement, execution of the intervening statements continues 
indefinitely. If an EXIT statement is encountered in the body of 
a DO loop, execution is transferred to the first statement following 
the nearest LOOP statement. Do loops may be nested, following the 
rules defined for FOR-NEXT loops. If the UNTIL parameter is used, 
the program continues looping until the boolean argument is satisfied 
(becomes true) , The WHILE parameter is basically the opposite of the 
UNTIL parameter: the program continues looping as long as the boolean 
argument is TRUE. An example of a boolean argument is A=l, or G>65. 

DO UNTIL X=0 or X=*l This loop will continue 

: statements until X-0 or X=l. If 

> LOOP X=0 or 1 at beginning, 

the loop won't execute. 

10 A$="": DO GETBEY A$: LOOP UNTIL A$«"Q'' This will loop until 

the user types- 'Q' 

10 D0PEN#1,"FILE" This program will 

20 C=0 count the number of 

30 DO: LINEINPUT#1,A$: C=C+1 : LOOP "UNTIL ST lines in FILE 

40 DOLOSE #1 

50 PRINT"FILE CONTAINS-;C; " LINES," * 

DOPEN - Open a disk file 

DOPEN#lf, "filename C,<S I F>1" [,L[reclen]] [,W] [,Ddrive] [<0N| ,>Udevicel ■ 

This coitiraand OPENs a file on disk for reading or writing. 
Lf is the logical file number, which you will use in PRINT*, INPUT#, 
GET#, RECORD!, and DCLOSE# commands to reference the channel to your 
file. The filename is required. The defaults are to OPEN a SEQuential 
file for Reading, in which case the file must exist or a 'FILE NOT 
FOUND' error results. To create an file and write to it, use the 
'Write option. 'FILE EXISTS' error is report if an output file 
already exists. To read or write a RELative file, use the 'L'ength 
option. The ' reclen' record length is required only when creating 
a relative file. For more information regarding Relative files, see 
the RECORD command and refer to your DOS manual. See also APPEND. 

See the OPEN command for a discussion about channel and device numbers. 



D0PEN#1, "readfile" Opens sequential READFILE for reading. 

DOPENJI; "writefile",W Creates & opens seq WRITEFILE for writing. 

SS!f^!3" "file/P^/UCu) Opens a PRoGram type file for reading on unit 

S2« !"'■' (rf$),L Open existing relative file whose name's in RFS 

DOPEN#a, "rel'',L80 Create a relative file with record length of 80 

DPAT - Set graphic draw pattern 

DPAT type C, # bytes, bytel, byte2, byte3, byte4] 

[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

type 0-63 

* bytes 1-4 

bytel 0-255 

byte2 0-255 

byte3 0-255 

byte4 0-255 

DSAVE - Save a BASIC program into a disk file 

DSAVE "[@ 3 filename" t/Ddrive] E<ON| , >Udevice] 

This command copies a BASIC program in the computer's BASIC meiRorv 
area into a PRoGram-type disk file. If the file already exists, 
the program is NOT stored and the error message 'FILE EXISTS' is 
reported. If the filename is preceded with an '@', then if the file 
S!^iS^^ ''^ "iw\?® replaced by the program in memory. Because of some 
problems with the 'save-with-replace' option on older disk drives, 
using this option is not -tetoitimended if you do not know what disk drive 
IS being used Use the DVERIFY to compare the program in memory with 
a program on disk. ' -<- ■» ^ ^^^ 

To save a binary program, use the BSAVE command. 

DSAVE "myprogram" Creates the PRG-type file MYPROGRAM 

on the default system disk and copies 

ncT^in? «/a „ ^^^ BASIC program in memory into it. 

UbAVE emyprogram" Replaces the PRG-type file MYPROGRAM 

with a new version of MYPROGRAM. If 

nqAVP (v<i\ no MYPROGRAM doesn't exist, it's created. 

-UbAVi:. {t^),\J3 Saves a program whose name is in F$ 

on disk unit 9. 

* 

DVERIFY - Coii^>are a program in memory with one on disk 
DVERIFY "filename" CDdrive] [<0N! , >udevice] 

This command is just like a DLOAD, but instead of LOADing the BASIC 
program file into computer memory the data is read from disk and 
compared to computer memory. If there's any difference at all a 
'VERIFY ERROR' is reported. 

Note: If the BASIC program in memory is not located at the same address 
as the version on disk was SAVEd from, the files will not match even if 
the program IS otherwise identical. The comparison ends when the last 
byte is read from the disk file. 

Use the BVERIFY command to compare memory with binary files . 

DVERIFY "myprogram" 



Good: SEARCHING FOR O:myprogram 
VERIFYING 
OK 



Badi SEARCHING FOR O:myprograni 
VERIFYING 
7VERIFY ERROR 



ELLIPSE - Draw an ellipse on a graphic screen 

ELLIPSE x_center, y_center, x_radius, y_radius "[, solid] 

The ELLIPSE command will draw an ellipse with the given radii centered 
at (x center, y_center) on the current graphic screen. The ellipse 
will 5e filled (i.e., a disc) if SOLID is non-zero. 

ELLIPSE 160,100,65,50 

The above example will draw an ellipse in the center of a 320x200 pixel 
screen (160,100) having radii of (65,50) pixels. The aspect ratio of 
the screen may cause it to appear as an circle, however. See also the 
CIRCLE command. 

ELSE - See IF/THEN/ELSE 

END - Define the end of program execution 

END 

The END statement terminates program execution. It does not close 
channels or files, and it does not clear any variables or reset any 
pointers. An END statement does not need to be put at the last line 
of a program. 

The CONTinue command can Tbe' used to resume execution with the next 

statement following the END statement. See also the STOP command. 



ENVELOPE - Define musical instrument envelopes 

ENVELOPE n, [, [atk] [, [dec] [, [sus] .[, [rel] [, [wf] [,pw] ]]]]] 

n Envelope number (0-9) 

atk Attack rate (0-15) 

dec Decay rate (0-15) 

sus Sustain rate (0-15) 

rel Release rate (0-15) 

wf Waveform: = triangle 

1 — sawtootb 

2 — pulse (square) 

3 — noise 

4 = ring modulation 
pw Pulse width (0-4095) 

[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

A parameter that is not specified will retain its current value. 
Pulse width applies to pulse waves (wf=2) only and is determined by 
the formula (pwout = pw/40.95 %) , so that pw = 2048 produces a square 
wave and values of or 4095 produce constant DC output. The C64DX 
initializes the ten (10) tune envelopes to: 

n A D S R wf pw inst rument 

ENVELOPE 0, 0, 9, 0, 0, 2, 1536 piano 

ENVELOPE 1,12, 0,12, 0, 1 accordion 

ENVELOPE 2, 0, 0,15, 0, calliope 

ENVELOPE 3, 0, 5, 5, 0, 3 drum 



ENVELOPE 4, 9, 4, 4, 0, flute 

ENVELOPE 5, 0, 9, 2, 1, 1 guitar 

l^^^ll ^' °' ^' °' °' 2. 512 harpsichord 

ENVELOPE 7, 0, 9, 9, 0, 2, 2048 orgL 

ENVELOPE 8, 8, 9, 4, 1, 2, 512 trinpet 

ENVELOPE 9, 0, 9, 0, 0, x^phone 

ERASE - Delete disk files 

ERASE "filespec" CDdrive] [<0N| ,>tJdevice] [,R] 

This command is identical to DELETE and SCRATCH. See the SCRATCH 
commana for details. 

ERASE "myfiie" Deletes the file MYFILE on the system drive. 

ERRS - Error message function 

ERR$ (error_nxiinber) 

^n^L^Ii"^^^°'' r^Ifr^ ^ string which is the BASIC error message 
?^o^™??? n ^ ^^^^^ f^''^'' error_message. If the given nmnbe? is 

qS^??T^' iltli is^^epir?fd!°° '^''^ *^^^^^^^ "^^^ ''' - '^^^^^^ 

?TIAl''r^i?n.^^,=?nS^i^ "'SfSr^'' display a BASIC error condition in 

L^r^v,?? i 'r-S®"-?^ ^^® ^^^^ ^^^°^ "o^^ ER as the error number. 

?n ^.^t^ r ^^""^ ""^ ^^^^^ ^^^°^ ^^s occurred and ER$ (-1) results 
in an illegal quantity error. -^v -^^ 

See the example at TRAP.- - 

EXIT - See DO/LOOP/HHILE/ONTIL/EXIT 

EXP - Function to return e'*'x 

EXP (nximber) 

This ftinction returns the numeric value of e (7 l^fi'>f^^f^'^\ *-h*» v,= ^« 
of natural logarithms) raised to the power If ^^iven n^^ir isthl 
number is greater than 88.0296919 an 'OVERFLOW' error^ reported 

X = EXPC4) Result is X=54.S981501 

FAST - Set system speed to 3.58MHz 

thf^ ^?^^^^Fn?f^''■^ ^^^^^ °^ ^^® system. FAST is used to restore 
SID%ound ch?ps? '''^ ^""^ ^^=^" "' "^'°"" ^^° ^^^i^-= --^ -- the . 

FETCH - (see the DMA conmiand) 

FILTER - Define sound filter parameters 

FILTER [freqj ^[Ipl [, [bp] [, [hp] [,r€S] ]]] 

^^6*? Filter cut-off frequency (0-2047) 

^P Low pass filter on (1), off (0) 

op Band pass filter on (1), off(O) 



hp High pass filter on (1)/ off(O) 

res ... Resonance (0-15) 

[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

Unspecified parameters result in no change to the current value. 
The filter output modes are additive. For example, both low pass and 
high pass filters can be selected to produce a notch (or band reject) 
filter response. For the filter to have an audible effect at least 
one filter output mode must be selected and at least one voice must be 
routed through the filter. 

FIND - Find text in a BASIC program. 

FIND .'String: [,line_range] 
FIND "string" [,line_rangej 

This is a direct (edit) mode command. FIND looks for all occurances 
of string in the program and displays- each line containing string, 
with string highlighted. Use the C= key to slow the display^ or the 
NO-SCROLL key to pause the display. Press STOP to cancel. 

Any character can be used for the string delimiter, but there are 
side effects. Using a non-quote delimiter will cause the string to 
be tokenized, and FIND will find only tokenized strings in the program 
that match. Using a quote character as the delimiter will cause the 
string to be interpreted as plain PETSCII/ and any matches found will 
therefore be plain PETSCII. Searching for some tokens such as DATA 
statements may require the use of colons as delimiters due to the 
special affect these commands have upon the interpreter. 

If the line number range -is-not given (see LIST for description of 
range parameter), the entire program is searched. 

FTJxx - User defined function 

FNxx (expression) 

The result of this -numeric function is determined by the BASIC program 
in a DEF FN statement. See the example at DEF FN. 

FOR/TO/STEP/NEXT - Program loop definition and control 

FOR index '^ start TO end [STEP increment] ' 

NEXT index [, index] 

This command group performs a series of instructions a given number 
of times. The loop index is a floating point (non-integer) variable 
which will initially be set to the start value and be incremented by 
the STEP increment when the NEXT statement is encountered. The loop 
continues until the index exceeds the end value at the NEXT statement. 

The start, end, and increment values can be numeric variables or 
expressions. If the STEP increment is not specified, it is assximed to 
be one (1) . The STEP increment can be any value, positive, negative, 
or non-integer. If the STEP increment is negative, the loop continues 
until the index is less than the end value at the NEXT statement. 

Note that, regardless of the start/ end, or increment values, the loop 
will alway execute at least once. The index can be modified within 
the loop, but it is bad practice to do so. It is also bad practice to 
GOTO a line inside a loop structure, or to similarly jump out of a 



loop structure (which can cause an out of memory error) ^ 

Loops may be nested. If too many are nested, an 'OUT OF MEMORY' error 
IS reported (depends upon stack size, room, for about 28 nested loops) . 

The index variable can be omitted from the NEXT statement, in which 
case the NEXT will apply to the most recent FOR statement*. If a NEXT 
statement is encountered and there is no preceeding FOR statement, - 
the error 'NEXT WITHOUT FOR' is reported. 

10 FOR L * 1 TO 10 

20 PRINT L 

30 NEXT L 

40 PRINT "I'M DONE! L = "L 

This program prints the numbers from one to ten, followed bv the 
message I'M DONE! L = 11, jr ^ 

10 FOR L == 1 TO 100 

20 FOR A = 5 TO 11 STEP .5 

30 NEXT A 

40 NEXT L 

This program illustrates a nested loop. 

FOREGRODND - Set the text color of the display 

FOREGROaND color 

Sets the text color to the given, color index. Color must be 
in the range (0-15). See the Color Table. COLOR must be ON (see 
the COLOR command) , — - 

7 

FRE - Free byte function 

FRE (X) 

This function returns the number of available ("free") bytes in a 
specified area. - ^ * j 

PRINT FRE(O) Shows the amount of memory left in the program area, 
C64DX bank 

X = FRE(l) ^^.^|i\^?"?^ °^ available memory in variable area, 
Cb4DX bank 1, This causes a "garbage collect" to 
occur, a process which compacts the string area. . 

X = FRE (2) X« the number of expansion RAM banks present, 

GCOPY - Copy a graphic area 

GCOPY x,y,dx,dy 
[*** NOT YET IMPLEMENTED ***] 

GENLOCK - Enable or disable video sync mode £ colors 

GENLOCK ON [, color #] . . . 
GENLOCK OFF C,color#, R,G,BJ . . . 

i^S/?lmS^^^5S° ^^"'^ "S^"^® ^""^ specify which colors are affected, use 
the GENLOCK ON command, and list the palette color indices (0-255) 



which will display external video. 

To disable video sync mode and restore the associated palette colors 
use the GENLOCK OFF command, and list the color index and its RGB ' 
values to restore them (see the SET PALETTE conimand for details! 
Also see the PALETTE RESTORE command, 

GET - Get input data from the keyboard 

GET variable_list 

The GET statement is a way to get data from the keyboard 
one character at a time. When the GET is executed, the 
character that was typed is received. If no character was 
typed, then a null (empty) character is returned, and the 
program continues without waiting for a key. There is no need 
to hxt the RETDRN key, and in fact the RETURN key can be 
received with a GET. The word GET is followed by a variable 
name, usually a string variable. .If a numeric were used and 
any key other than a number was hit, the program would stop 
with an error message. The GET statement may also be put into 
a loop, checking for an empty result, that waits for a key to 
be struck to continue. The GETKEY statement could also be used 
m this case. This statement can only be executed within a 
program. 

.10 DO: GET A$ : LOOP UNTIL A$ ="A" 
This line waits for the A key to be pressed to continue. 

GETKEY - Get input chaxaGter from keyboard (wait for key) 

GETKEY variable_list 

T^e GETKEY statement is very similar to the GET statement. 
Unlike the GET statement, GETKEY waits for the user to type a 
character on the keyboard. This lets it be used easily to wait 
for a single character to be typed. This statement can only be 
executed withm a program. 

10 GETKEY A$ 

This line waits for a key to be struck. Typing any key will 
continue the program. -^ = j ^ 

t 

GET# - Get input data from a channel (file) 

(SETfr logical_channel_nuniber, variable list 

Used with a previously OPENed device or file to input one 
character at a time. Otherwise, it works like the GET 
statement. This statement can only executed within a program. 

10 GET*1,A$ 

G064 - Exit C64DX mode and switch to C64 mode 

G064 

This statement switches from C64DX mode to C64 mode. The question 
'ARE YOU SURE?' (in direct mode only) is posted for the user to 
respond to. If Y and return is typed then the currently loaded 



program is lost and control is given to C64 mode. This statement 
can be used in direct mode or within a program, 

GOSDB - Call a BASIC subroutine 

GOSUB line 

This statement is like the GOTO statement, except that the 
computer remembers from where it came. When a line with a RETURN 
statement is encountered, the program jumps back to the statement 
immediately following the GOSUB. The target of a GOSUB statement 
is called a subroutine. A subroutine is useful if there is a section 
of the program that can be used. by several different parts of the 
program. Instead of duplicating the section over and over, it can be 
set up as a subroutine and called with a GOSUB statement from 
different parts of the program. This also make .the main part of your 
program much more readable. See also the RETURN statement. 

Variables _ are shared with the main program and all subroutines. You 
can pass information to, and get information back from, stibroutines 
by using variables as messengers. 

GOSUB statements can be nested. That is, one subroutine can call 
another subroutine, and the computer automatically keeps track of 
all the calls. It's important not to jump into or out of subroutines, 
since this can confuse the computer. If too many GOSUBs are nested 
(usually cause by jumping out of them) an 'OUT OF MEMORY' error is 
reported because the computer ran out of room to keep track of all 
the calls. 

10 DIR : GOSUB 100 show directory,, check status 

20 GOSUB 200 - - print gap 

30 LIST -PROGRAM": GOSUB 100 show listing, check status 

40 GOSUB 200 * print gap 

50 etc... 

90 END 

99: 
100 REM SUBROUTINE TO CHECK DISK STATUS 
110 IF DS THEN GOSUB 200: PRINT "DISK ERROR: ";DS$ 
120 RETURN 
199: 

200 REM SUBROUTINE TO PRINT A SPACER ON THE SCREEN 
210 PRINT 

220 F0RI=1T039:PRINT''-"; :NEXT 
230 PRINT 
240 RETtJRN « 

GOTO - Transfer program execution to specified line number 

GOTO line_number 
GO TO line_nuraber 

After a GOTO statement is executed, the next line to be 
executed will be the one with the line number following the 
word GOTO. When used in direct mode, GOTO line number allows 
starting of execution of the program at the given line number 
without clearing the variables. 

10 PRINT "COMMODORE" 
20 GOTO 10 

The GOTO in line 20 makes line 10 repeat continuously until STOP 
is pressed. 



GRAPHIC - select graphic mode 

GRAPHIC CLR 

GRAPHIC command*, [^args] 

Basically this is a modified C64-typ€ SYS command, minus the address. 
In the C64DX system, this will represent the ML interface, not the 
BASIC 10.0 interface which is implemented in the development system, 

[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

GRAPHIC CLR initializes (warm-starts) the BASIC graphic system. It 
clears any existing graphic, modes, screens, etc. and allows a program, 
to- commence graphic operations from scratch. 

HEADER - Format a diskette 

HEADER "diskname" [,IidJ CDdrive) [<0N| ,>Udevice] 

The HEADER command prepares a new diskette for use, sometimes 
called FORMATing a diskette. There are two types of "newing" a 
diskette- a long form and a quick (or short) form. You must use the 
long form when preparing a new diskette for its first use. Thereafter 
you can use the cjuick form. 

WARNING: Formatting a diskette (long or short) will destroy all 
existing data on the diskette! In direct mode, you are asked to 
confirm what you are doing with 'ARE YOU SURE?'. Type 'Y' and press 
return to proceed, or TYPE ANY OTHER CHARACTER AND PRESS RETURN TO 
CANCEL the command. In program mode there is no confirmation prompt. 

The long HEADER form requires a diskname and an ID. The diskette will 
be completely (re) sectored, zeros written to all blocks, and a new 
system track (directory, BAM, etc.) will be created. 
? 

HEADER "newdisk'MOl prepares a new diskette 

The short HEADER form is performed when the ID option is omitted. The 
diskette is assumed to have been previously formatted, and only a new 
system track (directory, BAM, etc.) is installed. This is roughly 
equivalent to deleteing all the files, but much quicker. 

HEADER "makelikenew" re-news an working diskette 

The diskname is limited to 16 characters and the ID string to two 
characters. The same rules apply for the diskname as for a filename. 
Some Disk Systems use the ID string to tell if you have swapped a 
diskette in a drive, so it's recommended that the ID string be unique 
for each of your diskettes. Some more examples: 

HEADER "QUICK" , 

HEADER "MYDISK", 123 

HEADER "RECS", I^FB", U9 

HEADER (FILE$), I (ID$) , UCUNIT) 

HELP - Show the BASIC line that cause the last error 

The HELP command is used after an error has been reported 
in a program. When HELP is typed, the line where the error occurred 
listed, with the portion containing the error highlighted. Print 
ERR$ (ER) for the error message, and print EN or EL for the error 
number and error line, respectively, HELP can be used in direct mode 
or in program mode. Note that, in the case of many I/O errors, there 



is no associated BASIC error. Check ST or DS$ errors in these cases. 

HEX$ — Hexadecimal value function 

HEX$ (decimal_expression) 

This function returns a 4 -character string that represents the 
hexadecimal value of the numeric decimal expression. The expression 
must be in the range (0-65535, $0000-$ETFF hex) or an 'ILLEGAL 
QUANTITY' error is reported. 

PRINT HEX$(10) The string "OOOA" is printed. 

PRINT RIGHTS{HEX$C10),2) .The string "OA" is printed. 

HIGHLIGHT - Set the text highlight color of the display 

HIGHLIGHT color 

Sets the highlight color to the given color index. The color value 
must be in the range (0-15). See the Color Table. COLOR must be ON 
(see the COLOR command) . The highlight color is used in HELP messages 
and FIND/CHANGE strings. 

IF/THEN/GOTO/ELSE - Conditional program execution 

IF expression <GOTO line | THEN then_clause> [:ELSE else_clause] 

IF... THEN lets the computer analyze a- BASIC expression 
preceded by IF and take one of two possible courses of action. 
If the expression is true", " the statement following THEN is 
executed. This expression c§n be any BASIC statement. If the 
expression is false, the pro9tam goes directly to the next 
line, unless an ELSE clause is present. The ELSE clause, if 
present, *iust be in the same line as the IF-THEN part. When an 
ELSE clause is present, it is executed when the TEIEN clause 
isn't executed. In other words, the ELSE clause executes when 
the expression is F_ALSE. See BEGIN/BEND to spread the IF statement 
out over several lines. An ELSE statement is matched to the 
closest THEN statement in the case of nested IF/THEN statements. 

The expression being evaluated may be a variable or formula, in 
which case it is considered true if nonzero, and false if zero. 
Usually expressions involve relational operators =, <, >, <=, >=, <>. 

50 IF X>0 THEN PRINT ■•X>0": ELSE PRINT "X<=0" 

If X is greater than 0, the THEN clause is executed, and the ELSE 
clause isn't. If X is less than or equal to 0, the ELSE clause is 
executed and the THEN clause isn't.. 

INPUT - Get input from the keyboard 

[LINE] INPUT ["prompt "<,!;>] variable_list 

The INPUT statement pauses the BASIC program, prints the prompt 
string if present, prints a question mark and a space, and waits for 
data to be typed by the user, terminated by a return character. If 
the prompt string ends with a comma instead of a semicolon, a question 
mark and space is not printed. 

Input is gathered and assigned to variables in the variable list. 
The type of variable must match the type of input typed or a 'TYPE ■ 



MISMATCH' error is reported. Separate data items typed -by the user 
must be separated with commas. String data with imbedded spaces or 
commas must be surrounded with quotes. If insufficent data to 
satisfy the variable-list is typed, two question marks are displayed 
by the computer to prompt for additional data to be input. If the 
computer does not understand the input (such as the user typing 
cursor up or down keys) the computer responds with the message 
'REDO FROM START?' and waits for acceptable data to be entered. 
Input is limited to 160 characters (two screen lines in 80-column 
mode), which is the size of the input buffer. 

The INPUT statement can only be executed from within a program. 

LINE INPUT allows the program to input a string which includes any 
PETSCII character (including colons, commas, imbedded spaces, etc.) 
up to but not including a null or return character. there should be 
only one string-type variable name in the variable list in this case, 
but if there are more the computer prompts as usual with two question 
marks for more data to assign to the additional variables. 

10 INPUT "WHAT'S YOUR FIRST NAME AND AGE"; NA3,A 

20 PRINT "YOUR NAME IS ";NA$;" AND YOU ARE";A;" YEARS OLD" 

The above INPUT is the traditional BASIC form. 

10 LINE INPUT "WHAT'S YOUR ADDRESS"; AD$ 
20 PRINT "YOUR ADDRESS IS: ";AD$ 

The above INPUT allows an entire line of data to be assigned to a 
string variable, including commas and other common punctuation marks. 

10 INPUT "ENTER YOUR NAME HERE: ", NA$ 

The above INPUT suppresses the traditional ' ? ' prompt by using a comma 
instead of a semicolon after the prompt string. To suppress the '? ' 
without a prompt string, make the prompt string null, 
7 

INPUT# - Input data from an I/O channel (file) 

[LINE] INPUT#logical_channel_number, variable_list 

The INPUT* command works like the INPUT command, except no prompt 
string is allowed and input is gathered from a previously OPENed 
channel or file. This command can only be used in a program. 

The logical_channel_number is the number assigned to the^ device (file) 
in an OPEN (or DOPEN) statement. Items in the variable list must 
agree with the type of data input, or a 'FILE DATA ERROR' will result. 

On the C64pX, an End Of File (EOF) condition or bad I/O status will 
terminate input, as if a return character was received. It's good 
practice to examine the I/O status byte (and the DS disk status for 
file I/O) after every I/O instruction to check for- problems or errors. 

10 D0PEN#1,"FILE" This program will 

20 C-0 count the number of 

30 DO: LINEINPUT#1,A$: C==C+1 : LOOP UNTIL ST lines in FILE 

40 DCL0SE#1 

50 PRINT"FILE CONTAINS";C; " LINES." 

INSTR - Get the location of one string inside anothei: string 

INSTR (string_l, string_2 C# starting_position] ) 



This function searches for the first occurrence of string 2 in 
string_l and returns its location. A value of zero (0) is returned 
ir no match is found, if either string is null (empty), or if 
string_2 is longer than string^l. v t^ y/, r xx 

If the starting_j)osition is given, the search begins at that location, 
otherwise the search begins at the first character of string_l. 

The strings can be literals, variables, or string expressions. 



X = INSTR("123456", "4") 
X * INSTR<"123456","X") 
X = IKSTR("123123*', "2") 
X = INSTR("123123","2",3) 



Result is X-4 
Result is X=0 
Result is X-2 
Result is X=5 



IMT - Greatest integer function 

INT (expression) 

This function returns the greatest integer less than or equal to 
the numeric expression. 



X = INT{ .123) 

X = INT (-.123) 

X = INT( 123.456) 

X = INT(-123.456) 



Result is X= 
Result is X= -1 
Result is X= 123 
Result is X=-124 



JOy - Joystick function 



JOY (port) 



This function returns the state of a joystick controller in the 
specified port. * 

When port=l returns position of joystick 1 
When port=2 returns position of joystick 2 

The value returned is encoded as follows: 
Fire - 128 + X 

8 2 



A value of zero (0) means that the joystick is not being manipulated, 
A value of 128 or more means that the fire button is being pressed. 
The possible vales returned are: 



No activity 

up 

up + right 

right 

right -t- down 

down 

down + left 

left 

left + up 



128 
129 
130 
131 
132 
133 
134 
135 
136 



fire 

fire 
fire 
fire 
fire 
fire 
fire 
fire 
fire 



up 

up + right 

right 

right + down 

down 

down + left 

left 

left + up' 



KEY - Enable r disable, display/ or define function keys 

KEY ON 

KEY OFF 

KEY [key#, string] 

There are 14 function keys available on the C64DX (seven linshifted 
and seven shifted) . The user can assign a string consisting of 
BASIC commands, control codes, escape functions, or a combination 
of each to function key. The data assigned to a key is typed out 
when that key is pressed, just as if the characters were typed 
one by one on the keyboard. The user can enable ("turn on") or 
disable ("turn off) the function keys. When they are disabled, 
pressing a function key return that key' s normal character code 
instead of the string assigned to it. This includes the HELP and 
(shifted) RUN keys. It is also possible to redefine the HELP and 
(shifted)RUN keys, as function keys 15 and 16, respectively. The 
system has default assignments for all function keys. KEY with no 
parameters displays a listing of the current assignments for all the 
function keys. 

The maximum length for all the definitions together is 240 characters. 
If an assignment would be too big to fit, an 'OUT OF MEMORY' error 
is reported and the assignment is not made, 

KEY 2, "DIR U9"-f-CHR$(l3) 

This causes the computer to display the directory from disk 
unit #9 when function key 2 is pressed. This is equivalent to 
typing 'DIR U9' and pressing the RETURN key directly. The CHR$(13) 
is the character for RETURN. Other often used control codes are 
CHRS(141) for 'shifted RETURN', CHR$(27) for 'ESCape', and CHR$(34) 
to incorporate a double qtiote into a KEY string. 

KEY 2, "DIR"+CHR$C34)+"*=P"+CHRS(34)+CHR$(13) 

T'jis is equivalent to typing DIR"*=P'* and pressing return 
at the keyboard. Note the way quotes can be incorporated into an 
assignment. When function key 2 is pressed, a directory of all 
program files on the default system disk will be displayed. 

(^ KEY OFF 

This turns off function key strings. Pressing a function 
key now would return the character codes associated with F-keys as 
on the VIC-20 and C64 computers. KEY ON would re-enable function 
key strings, unchanged from their previous assignments.* To restore 
the system default assignments, reset the computer. 

I£FX$ - Get the leftmost characters of a string 

LEFT$ (string^ count) 

This function returns a string containing the leftmost 'count' number 
of characters of the string expression. Count is an numeric 
expression in the range (0-255) . If count is greater than the length 
of the string, the entire string will be returned. If count is zero, 
a null (empty) string will be returned. 

A$ = LEFT5C"123ABC",3) Result is A$=«123'* 

LEK - Get the length of a string 

LEN (string) 



This f-unction returns the number of characters in a string expression. 
Nonprinting characters and blanks are counted. 

A = LEN("ABC") Result is A=3 

I£T — Assign a value to a vajciable 

(LET) variable - expression 

The LET command is optional, since the equal sign by itself is 
understood by the computer to mean assignment. Multiple assignments 
on LET statements are not allowed. 

10 LET A=l: LET B=A+1: LET C$=" THREE" 
20 : D=l: E=D+1: F$=" THREE" 
30 PRINT A;B;C$ 
40 PRINT D;E;F$ 

Output: 1 2 THREE 

X 2 THREE 

LINE - Draw a line on a graphic screen 

LINE xO, yO, xl, yl 

LINE draws a line on the currently defined graphic screen with 
the currently defined draw modes. The line is draw from (xO,yO) 
to (xl,yl) . 

LIST — List a BASIC prograxs l^om memory or disk 

LIST [ startline ] [ - [ endline ] ] 

LIST "filename" [,Ddrive] [<, |ON>Udevice] 

LIST is used to view part or all of a BASIC program in memory or all 
of a BASIC program on disk (without affecting the program that is 
currently in memory), ■ ' 

The display can be slowed down by holding down the C- key or it 
can be paused by pressing the NO-SCROLL key or CONTROL-?. A listing 
that is paused can be restarted by pressing NO-SCROLL again or by 
pressing CONTROL-Q, The display can be stopped by pressing STOP, 

If the word LIST is followed by a line number, the computer shows 
only that line nxamber. If LIST is typed with two numbers separated 
by a dash, the computer shows all lines from the first to the second 
line number. If LIST is typed followed by a number and just a dash, 
it shows ail lines from that number to the end of the program. 
And if LIST is typed, a dash, and then a number, all lines from the 
beginning of the program to that line number are LiSTed. By using 
these variations, any portion of a program can be examined or easily 
brought to the screen for modification. LIST can be used in direct 
mode or in a BASIC program. 

LIST Shows entire program. 

LIST 100- Shows from line 100 until the end of the program. 

LIST 10 Shows only line 10. 

LIST -100 Shows lines from the beginning until line 100. 

LIST 10-200 Shows lines from 10 to 200, inclusive. 



LOAD - Zoa6. a program or data into memory from disk 

LOAD "filename" [,device_nuinber C^relocate_flag] ] 

This command loads a file into the computer's memory. The filename 
must be given, and pattern matching may be used. In the dase of dual 
drive systems, the drive number must be part of the filename. If a ■ 
device number is given, the file is sought on that unit, which must be 
a disk drive. If a device number is not given, the default system 
drive is used. See also DLOAD and RUN commands. 

The relocate_f lag is used to LOAD binary files . If the relocate_f lag 
is present and non-zero, the file will be copied' into memory starting . 
at the- address stored on disk when the file was SAVEd. See BLOAD. 
Do not use the relocate_flag to load BASIC programs; they will be 
automatically relocated to the start of the BASIC program area and 
relinked. 

To compare a program in memory to a disk file, use the VERIFY or 
DVERIFY command. To compare a binary file, use BVERIFY. 

See the discussion at DLOAD regarding CHAINING programs. 

LOAD "PROG" Loads BASIC program PROG from the system drive. 

LOAD FILE$,DRV Loads a program whose name is in the variable 

called F$ from the unit whose number is in DRV. 
LOAD "0:PROG",8 Loads BASIC program PROG from unit 8, drive-0. 
LOAD "BIN"/ 8,1 Loads a binary file into memory. 

LOCATE - [*** NOT YET IMPLEMENTED'***] 

LOG - Get the natural logarithm of a nmuber 

"> LOG (number) 

This function returns the natural logarithm of a numeric expression. 
A natural log is a log to the base e (2.71828183). See the EXP 
function. To convert to log base 10, divide by LOG (10) . 

A = LOG(123) Result is AM. 81218436 

A = LOG(123) / LOG(IO) Result is A=2. 08990511 

LOOP - See DO/LOOP /HHILE/TJNTIL/EXIT * 

LPEN — Get the position of a lightpea 

PEN (position) 

This function returns the current position of a lightpen on the screen 
When position=0, the X position is returned* and when positional the 
Y position is returned. Note that lightpen coordinates, like sprite 
coordinates, are offset from the normal graphic coordinate map. This 
means you have to calculate where the lightpen is with respect to the 
screen display. The electronics of each lightpen also introduces a 
skew which must be factored into your calculations. 

The X resolution is limited to every 2 pixels, and will always be an 
even number in the approximate range (60-320) . The Y position is in 

the approximate range (50-250) . If either the X or the Y position is 
zero, the lightpen is off -screen. 



Note that a lightpen COLLISION need not be enabled to use LPEN, 
bright background color, such as white, is usually required to 
stimulate the light pen. Lightpens only work in game port 1. 



10 TPAP 40 

15 BACKGROUND 1 

16 FOREGROUND . 
20 COLLISION 3/100 
30 DO: LOOP 

40 END 
100 COLLISION 3 
110 PRINT LPEN(O) ,LPEN(1) 
120 COLLISION 3,100 
130 RETURN 



We're done if STOP key 
Make backgound color white 
Make text' color black 
Enable lightpen interrupt 
Hang here until done 
Done 

Got one, don't want more 
Display lightpen position 
Re-enable interrupt 



MID$ — Substring function 

MID$ (string, position [, length}) 

This function can appear on the left or the right side of an 
assignment statement: 

Case 1: string_var == MID5 (string_expression, position [, length]) 

This form returns a piece of another string. The function returns a 
stringof the specified length taken from the string expression 
beginning at the indicated position. The position must be in the 
range (1-255), one (1) being the first character. The length can be 
any number in the range (0-255), or it can be omitted. If the position 
specified is greater than the number of characters in the 
string_expression, a null (empty) string is returned. If the length is 
greater than the number oT characters from the given position to the 
end of the string_expression. or the lenght is omitted, then all the 
rightmost characters beginning at the position are returned. 



A$ = MID${"TICTACTOE",4,3) 
A$ = MID$ ("TICTACT0E",4) 
A$ = MID$("TICTACTOE",10,1) 



Result is A$="TAC" 
Result is A$-"TACTOE" 
Result is A$="" (empty) 



Case 2: 



MID5 



(string_var, position [, length]) = string_expression 



This form replaces a portion of the string contained in string var 
with datafrom another string_expression, beginning at the specified 
position in the string_var. If the length is given only, that many 
characters from the string_expression are taken, otherwise all the 
characters in the string_expression will replace characters in the 
string var beginning at the position specified. The there are too 
many characters to fit in the string_jvar, an 'ILLEGAL QUANTITY' error 
is reported. If the length given is zero, no characters will be 
replaced. 




MONITOR - Enter the built-in machine language monitor 

SEE SECTION ? . ? ON THE C64DX MONITOR. 



MOUSE - Enable or disable the mouse driver 

MOUSE ON Cport [, sprite [, position] ] ] 



MOUSE OFF 

port = joyport 1, 2, or either (both) (1-3) 
sprite = sprite pointer (0-7) 

position = initial pointer location (x,y) 

normal, relative, or angluar coordinate 

defaults to sprite 0, port 2 
???? add min/max x/y positions 

[*** THIS COMMAND IS SUBJECT TO CHANGE ***] 

Mouse ON enables the built-in mouse driver. The user must load 
a pointer into the proper sprite area ($600-$7FF)\ The driver 
assumes the "hot point" is the top left comer of the sprite, 
and does not allow this point to leave the screen. 

Mouse OFF will turn off the driver and the currently associated 
sprite. 

Use the RMOUSE function to get the current pointer position and 
button status. See the sample program at RMOUSE. 

MOVSPR — Position sprite or set sprite in oration 

MOVSPR sprite <,x,y> 

Use the SPRITE command to turn on a sprite, and MOVSPR to position 
it. Sprites are numbered 0-7. The sprite's position can be specified 
using one of the following coordinate types; 

[+/-]x, [+/-]y ='*[felativel position 
x#y = angle and speed 
x;y = distance and angle 

A-3^1es are specified as 0-360 degrees, with being straight up. 
Speeds are specified as a niimber of pixels per frame, 0-255. Sprites 
are moved through each pixel so that collisions are accurately detected. 

NEW - Delete program in memory and clear all vsuriables 

NEW [RESTORE] 

This command erases the entire program in memory and clears all 
variables and open channels (but it does NOT properly ciose open 
disk write files- used DOLOSE or DCLEAR beforehand) . NEW also 
resets the runtime stack pointer (clears GOSUB S FOR/NEXT stacks) , 
the DATA pointer, and the PRINTUSING characters. 

The BASIC program in memory is lost unless it was previously SAVEd 
to disk. If you have not entered or loaded any BASIC programs since 
typing NEW, the RESTORE option will recover the BASIC program in 
memory. But if the BASIC environment has been changed in any way, the 
program may not be restored correctly. If BASIC can tell something's 
wrong, it will report 'PROGRAM MANGLED' . 

NEW can be used in direct (edit) mode or in a program. When it's 
encountered in a program, the program terminates . 

NEXT - See FOR/NEXT/STEP and RESUME 

NOT ' Get the complement o£ a number 



NOT (expression) 

T^?o?2o 5''^?^i?;. ''®^^^'*® ^^® complement of an integer in the range 

na iJ^ ' 2 -^2767). The function operates on the binary value of sianed 

'l£LEGAi"QuIST!iY''^rro?"'''°" ^^^"'""^ °^ ^"^^^ "^^^- "''^ "^^^^ ^^ 

X - NOT (5) Result is X=-6 

X = NOT (-6) Result is X=S 

inLi? ^^^^'^ ""^f? in logical comparisons (such as an IF. statement) to 

n T?f?^o^^-^®?I?^^' ^'■?''® "^ f^^^®* ^2 ^^^ result of NOT(O) (false . and 
(false) is the result of NOT(-l) (true). 

X = NOT{"ABC"="ABC") AND ("DEF«=''DEF") Result is X= ii^^i^^^ 

OFF - Subcommand used with various BASIC commands. 

OH - Computed GOTO/GOSDB 

ON expression <GOT0|G0SDB> line_number_list 

^!j^Li^^? variation of the IF<expression>GOTO statement that branches 
tL ?n^° several line numbers based upon the value of an expression. 

nSShi^ ?rf>,''^}'^® °^ ^^^ evaluated expression determines which line 
number m the line_number_list gets control. 

ILV'^r.t'^l'^^^^^T ■fY^^'i^^^K^'' °"®' ^^^ ^^^st line number in the list 
In ?°S^f°i: t^ ^K^ ^"J" l^^ ^?^°"^ ^^"^ ^^'^^^ 5^ts control, and so 
S^;.J^ 5f^''?i f?""^^ ?^ ^^^ ¥^^^^ ^^^ truncated (for example 2,9 
?n ?Se I?i; hh^ n^^ ^?^^%^S ^^^° °^ 5^^^^^^ ^^^" th^ number of ilems 
iith ?hi nL^ V r^''^!'' takes none of the branches and continues on 

In^ ?U^^°^5P Statement must call the first line number of a subroutine, 
and the subroutine must end with a RETURN statement. After executing 

ON/GSsS^°Statl;eS??'^"' '' "^""""^ ^° the statement following the 

10 INPUT"ENTER A NUMBER 1-3: ",X 

20 ON X GOTO 100,200,300 

30 PRINT"TOO LOW OR TOO HIGH": RUN ' 

100 PRINT"ONE": RUN 

200 PRINT"TWO": RON 

300 PRINT "THREE": RUN 

OPEN - Open a channel to a device or disk file 

OPEN logical_chnl_num, device_number [,secondary_adr C,<filespec|command>] ] 

h^^n^Lin^r^^f^'.'^^" access a device or a file, an I/O channel must 
be opened to it to communicate through. When something is opened, 
you associate a logical channel number with it, and it is with this 
number that all other l70 statements access th4 device or file. tL 
OPEN command can be used in direct (edit) mode or in a program. 

The channel number, device number, and optional secondary address 
are integers from 0-255. Refer to the device's manual for more 
information about what (if any) secondary addresses it uses. 



channel; 0-127 return = output return character only 
128-255 return - output return + linefeed 

device: Keyboard 

1 Default system drive 

whatever its number is (see SET DEF) 

2 RS232 

3 Screen 
4-7 Serial bus 

(usually reserved for printers) 
8-31 Serial bus 

(usually reserved for disk drives) 

The filespec is the file name in the case of disk files (refer to 
your DOS manual for details) . Typically, the filename ia a string 
having the the following form: 

[ [S !$] drive: ] filename [/type] [/mode] 

An excimple would be 0:MYFILE,SEQ,READ to open the sequential 
file MYFILE for reading on drive 0, Disk drives usually support 
some kind of filename pattern matching. Most disk drives support the 
following file types and modes (can- be abbreviated to first character) : 

types : ' S' eguential 
' P ' rogram 
'R'elative 
'U'ser 

modes: 'R'ead 

'Write 
'L'ength (for relative type files) 

Some channels or devices accept a command string instead of a filename 
when they are opened. An e:?ampie would be the disk command channel or 
the RS232 open/setup command. Refer to the device's documentation. 

OPEN 1,8, 15, "I" Open CBM disk command channel & send 

it the 'I'nitialize command. 

OPEN 4,4,7 Open CBM printer channel in upper/lower 

case mode. 

OPEN 128,2,2,CHR$(14) Open a 9600 8N1 RS232 channel and 

translate CR into CRLF on output. 

See also DOPEM, DCLOSE, CLOSE, CMD, GET#, INPUTt, and PRINT# statements 
and I/O status variables ST, DS, and DS$. 

OR — Boolean operator 

expression OR expression 

The OR operator returns a numeric value equal to the logical OR 
of two numeric expressions, operating on the binary value of signed 
16-bit integers in the range (-32768 to 32767) . Numbers outside this 
range result in an 'ILLEGAL QUANTITY' error. 

X = 4 OR 8 Result is X=12 

In the case of logical comparisons, the numeric value of a true 
situation is -1 (equivalent to 65535 or $FFFF hex) and the numeric 
value of a false situation is zero. 

X « ("ABC"="ABC") OR ("DEF"="DEF") Result is X*-l (true) 
X - ("ABC"="ABC") OR ("DEF"="XYZ") Result is X=-l (true) 
X « (•'ABC"="XY2") OR ("DEF"="XYZ") Result is X= (false) 



PAINT - Fill a graphics axea with coloi: 

PAINT x,y, mode [, color] 

x,y coordinate to begin fill at 
mode 0; fill area to edge = color 

1: fill area to edge=same as color at x,y 

^^J?^^£^^^^,^ enclosed graphic area starting at the given coordinate 
wxth the color of the currently defined PEN. The mode parameter 
identifxes the region to be filled. 

[*** THIS COMMAND IS NOT YET IMPLEMENTED ***] 

PALETTE - Define a color 

PALETTE [screen* I COLOR), color*, red, green, blue 
PALETTE RESTORE / «j.uc 



screen* 


0-1 


color* 


0-255 


red 


0-15 


green 


0-15 


blue 


0-15 



The PALETTE command can be used to define a color for a logical 
graphic screen, set an absolute color, or restore the C64DX VIC-III 
default colors. PALETTE can be used in direct mode or in a program. 

The VIC-III pre-defines the first 16 colors to the usual C64-type 
colors, but you can change them with the PALETTE COLOR command or 
restore them- all with the PALfiTTE RESTORE command. 

See the sample program after -the SCREEN command. 

PASTE - Put a CUT graphic area on the screen 

PASTE x,y 
[*** NOT YET IMPLEMENTED ***] 

PEEK - Function returning the contents of a memory location 

PEEK (address) 

This function returns the contents of a memory location. The address 
must be an integer in the range of 0-65535 ($0-$FFFF) and the value 
returned will be an integer m the range of 0-255 ($0-SFF) . 

Use the BANK command to specify which 64K memory bank the address 
"•^.i^Zu ^°^^ ^^^^ * ^^^ number greater than 127 (i.e., a bank number 
with the most significant bit set) must be used to address an I/O 
location, such as the VIC chip or color memory. Refer to the system 
memory map for details. PEEK uses the DMA device to access memory. 

Use the POKE command to change the contents of a memory location. 

BANK 0: X - PEEK (208) Reads the keyboard buffer index. If 

it's empty, X will be zero, otherwise X 
will be the number of characters in it. 



PEN — ^ecify a. pen color- for drawing on gi^phic screen 

PEN pen, color 

pen 0-2 

color 0-255 

Before you can dxaw anything on a graphic screen, you have to tell 
BASIC what color your PENs are. You should first define what your 
colors are using the PALETTE command, then use PEN to associate those 
colors with a PEN. Whatever graphic commands you use after a PEN 
command will use the PEN you specified. 

PEN 0,1 Put color 1 "ink" into draw pen 

See the sample program after the SCREEN command.- 

PIC — Graphic picture sobconmiand 

PliAX - Play a musical string 

PLAY "[Vn,On,Tn,Un,Xn,eiements]" 

[*** WILL CHANGE TO ADD 2nd SID SUPPORT ***] 

The PLAY command lets you select a voice, octave, instrument, volxime, 
filter, and musical notes. All these parameters are packed into a 
string (spaces are allowed for readability) . 

On = Octave (n=0-6) 

Tn = Tune envelope # (n=0-9) 

0= piano (defaults) 

1= accordion 
> 2= calliope ♦ 

3= drum 

4= flute 

5« guitar 

6= harpsichord 

7= organ 

8- trumpet 

9- xylophone 
Un = Volume (n-0-9) 
Vn = Voice (n=l-3) 

Xn = filter on (n=l) , off (n=0) , 

Elements: 

A,B,C,D,E,F,G ,,, Notes, may be preceeded by: 

# Sharp 

$ Flat 

Dotted 

W Whole note 

H Half note 

Q Quarter note 

I • Eighth note 

S Sixteenth note 

R Rest 

M. . . Wait for all voices playing to end 

(a measure) 

Once the music string starts PLAYing, the computer will continue with 
the next statement. The music will continue to play automatically. 
Using the 'M'easure command will cause the computer to wait until the 
music has up to that point has been played out. 



Use the TEMPO command to alter the tempo (speed) of PLAY. Note that 
the voLunte command can change a PLAY string's volume setting. 

POIHTER - Get the address of a variable descriptor 

POINTER (variable_name) 

?5^^w^^"*^^°'^ returns the address of an entry in the variable table. 
If the value returned is zero, the variable is currently undefined. 
The varxable table is normally in the second RAM bank (BANK 1) . See 
the section on variable storage for details. 

Note that, while the location of a string descriptor will not change, 
trie location of the actual string in memory changes all the time. 
Also, when working with an array name you must specify a particular 
element, to which POINTER will return a pointer to that element's 
descriptor and not to the array descriptor. 

10 A$-"FRED" Define A$ 

20 DESC-POINTER (A$) Lookup A$ in variable table 

30 BANKl: PRINT PEEK{DESC) Displays -the length of A$ 

POKE - Write a byte to memory location 

POKE address, byte [,byte ...] 

POKE is used to write one or more bytes into one or more memory 
/SS^t^SSS: ^5® address must be an integer in the range of 0-65535 
(50-9FFFF) and the value to be written must be an integer in the 
range of 0-255 ($0-SFF) . If more than one byte is given, it will 
be written into successive memory locations. 

Use the BANK command to specify which 64K memory bank the address 
"^^^t^U Note that a BANK number greater than 127 (i.e., a bank number 
with the most significant bit set) must be used to address an I/O 
location, such as the VIC chip or color memory. Refer to the system 
memory map for details. Also note that, unlike previous CBM computers 

p?^? """"J '^°^ iS^^^^^'^ "^^1 '^^^ "^^^^<^ through" into a correSponSing 
RAM location. POKE uses the DMA device to access memory. 

Use the PEEK function to read a byte from a memory location. 

Because this command directly accesses system memory, extreme care 
Should be taken in its use. Altering the wrong memory Jtocation can 
crash the computer (press the reset button to reboot) , 

BANK 0: POKE 208,0 Resets location 208 (SOOODO) , clearing 

the keyboard buffer. 

BANK 128: POKE DEC ("D023") , 1, 2, 3 Sets the VIC extended background 

colors to 1, 2, and 3 respectively 

POLYtMN - Draw a regular n-sided figure on a graphic screen 

POLYGON x,y, xradius, yradius, [solid], angle, drawsides, sides, subtend 

x,y — center of polygon 

X, yradius - radii of polygon 

solid « solid flag . (0-1) 

angle = starting angle (0-360) 

drawsides = # of sides to draw (3-127) 

^i^®s - * sides of polygon (drawsides<-sides) 



subtend = subtend flag (0-1) 

FOS — Ge't the column nunLbex* o£ the cuxsor' 

POS (0) 

This function returns the current text column the cursor is in, with 
respect to the currently defined window (see RWIIJDOW)'. It's usually 
used to fonaat text printed to the screen. The argument (0) is 
not used for anything. POS will not work as expected if text output 
is redirected to a disk file or the printer. 

10 MAXCOL = RWINDOW(l) 

20 FOR ADR=DEC("600") TO DEC("7FF'*) 

30 PRINT HEX$ (PEEK (ADR) ) ; " "; 

40 IF POS(O) > (MAXCOL-5) THEN PRINT 

50 NEXT 

This example illustrates one way to format output to the screen, 
keeping the last item on a line from being split between two lines, 
regardless of the window size (as long as the window size is at least 
4 characters wide) , It dumps the data for the first sprite in hex, 

POT - Paddle function 

POT (paddle) 

This function returns the state of a game paddle (POTentiometer) 
controller in one of the two game ports. 

paddle=l Position of paddle #1 (port 1, paddle "A") 

paddle=2 . Position of paddle #2 (port 1, paddle "B") 

paddle=3 Position of paddle #3 (port 2, paddle "A") 

paddle=4 Position of paddle #4 (port 2, paddle "B") 

y 
The value returned by POT ranges from to 255, Any value greater 
than 255 means that the file button is also pressed. Paddles are 
read "backwards" from normal things like volume knobs or faucets. 
A value of 255 means the paddle has been turned counterclockwise 
as far as it will go ("off"), and a value of means the paddle has 
been turned clockwise as far as it will go. ("on"). 

Note that some paddles are "noisy" and their output must be averaged 
or "damped" to prevent whatever they are controlling from jittering. 

10 SPRITE 1,1 Turn on a sprite 

20 DO Begin a loop 

30 X=P0T(3) Read paddle "A" in port 2 

40 MOVSPR 1,300-(X AND 254), 200 Move the sprite 

50 LOOP UNTIL X>255 Loop until button pressed 

60 SPRITE 1,0 Turn off sprite 

This sample program turns on a sprite and lets you move it horizontally 
with a paddle. If you press the paddle's fire button, it turns off the 
sprite and the program ends. The calculations in line 40 do several 
things all at once- they mask the fire button and "damp" the output to 
reduce jitter by masking the least significant bit (the X AND 254 part) 
and invert the output so that turning the paddle to the right makes the 
sprite go right (subtracting result from 300) . 

PRINT - Display data on text screen 

PRINT [expression_list] [<, | ;>] 



PRINT will evaluate each item in the expression_list and pass the 
results to the system screen editor to display on the screen. If 
a screen window is defined, the output will be confined to the window. 
PRINT can be used to send control codes and escape sequences to the 
screen editor to do such things as set windows, change TAB stops, 
change text colors or set reverse field, or choose cursor styles. 
See the section on Editor modes for details. 

PRINT can be followed by any of the following: 

Numeric or string expressions 12, "HELLO", l+i, "$"+STR$(I) 

Variable names A, B, A$, X$ 

Functions ABS(33), HEX$ (150) 

Punctuation marks ; , ' 
Nothing 

Numeric values are always followed by a space. Positive numbers are 
preceeded by a space, and negative numbers are preceeded by a minus 
sign ('-') . Scientific notation is used when a number is less than 
0.01 or greater than or equal to 999999999.2. 

A semicolon (':') or space between list items causes the next item 
to be prxnted immediately following the previous item. A comma 
(',') causes the next item to be printed at the next comma stop 
(similar to TAB stops, but every 10 spaces) , These rules apply to 
the next print statement if the expression_list ends with either 
a semicolonor a comma, otherwise a return is printed. Note that 
floating point variable names should not be separated from the next 
variable name with a space, and constants should not be preceeded 
or followed by a space. 

For formatted PRINT output, see the PRINt' USING command. 

PRINT "HELLO" > HELLO 

A$="THERE": PRINT "HELLO ";A$ HELLO THERE 

A=4:B-2: PRINT A+B 6 

J=41: PRINT J;: PRINT J*l 41 40 

C=A+B:D=B-A: PRINT A;B;C;D 4 -2 6 -2 

C*A+B:D=B-A: PRINT A,B,C,D 4 2 6-2 

A=1:B=2:AB'=3: PRINT A B 3 

PRINT 1 2 3, 1 2 3 +1 123 124 

PRINT 0.009, 0.01 9E-03 01 

PRINT 999999999; 999999999.2 999999999 ' lE+09 

The CMD command can be used to redirect PRINT output to a device or 
file. Also see the POS, SPC, TAB functions, CHAR and PRINT USING. 

PRINT* - Send data to an I/O channel (file) 

PRINT#logical_channel_number [,expression_listl £<, j ;>] 

This cotiunand is used to send (transmit) data to a device or file. 
The logical_channel_number is the number assigned to the device (file) 
in an OPEN (or DOPEN) statement. The output is otherwise identical to 
that of a PRINT statement, including the comma and semicolon 
conventions. Note that certain screen-oriented functions, such as 
TAB and SPC do not have the same effect as they do with screen I/O. 



It's good practice to examine the I/O status byte (and the DS disk 
status for file I/O) after every I/O instruction to check for problemis 

or errors. 

For formatted output, use the PRINT* USING command. 

10 OPEN 1,8,15 Initialize disk drive 

20 PRINT#1,"I" (same as DCLEAR) 

30 CLOSE 1 

10 D0PEN#1,"NEWFILE'',W Create a SEQ file 

20 FOR I=lTO10 

30 PRINT#1, I,SXR$(I) Write numbers 1-10 -to it 

40 NEXT 

50 DCL0SE#1 

10 OPEN 2,2,2;CHR$(12) Open 1200 baud RS232 channel 

20 PRINT#2, "ATDT, 5551212" Send modem a Hayes dial coinmand 

PRINT USING - Output formatted data to the screen, device, or file 

PRINT [#logical_channel_number, ] USING format; expression_list [<,!;>] 

Read about the PRINT and PRINT# commands first for information 
regarding the syntax of the expression_list and, for device output, 
establishing the logical_channei_nuraber. 

The items in the expression list must be separated by commas (','). 

The format is defined in a string literal or string variable and is 
described below. See the PUDEF command for specifing special 
formatting characters. The various formatting characters are: 

CHARACTER SYMBOL NUMERIC STRING 



' Pound sign # XX 

Plus sign + x 

Minus sign - X 

Decimal Point . X 

Comma , X 

Dollar Sign ~ $ X 

Four Carets ^saa.* . ., ^ 

Equal Sign = X 

Greater Than Sign > X 

The pound sign ('#') reserves room for a single character in the 
output field. If the data item contains more characters ^han the 
number of pound signs in the format field, the entire field will be 
filled with asterisks ('*') . 

10 PRINT USING "####";X 

For these values of X, this format displays: 
A = 12.34 12 
A = 567.89 568 
A « 123456 **** 

For a STRING item, the string data is truncated at the bounds of the 
field. Only as many characters are printed as there are pound signs 
in the format item. Truncation occurs on the right. 

The plus ('+') and minus ('-') signs can be used in either the first 
or last position of a format field but not both. The plus sign is 
printed if the number is positive. The minus sign is printed if the 
number is negative. 



If a minus sign is used and the number is positive, a blank is printed 
in the character position indicated by the minus sign. 

If neither a plus sign nor a minus sign is used in the format field 

^^j^i^^^®^^^ ^^^^ item, a minus sign is printed before the first digit 
or dollar symbol if the number is negative and no sign is printed if 
the number is positive. This means that one more character is printed 
If the number is positive. If there are too many digits to fit into 
the field specified by the pound sign and +/- signs, then an overflow 
occurs and the field is filled with asterisks ('*'). 

A decimal point ('.') symbol designates the position of the decimal 
point in the number. There can be only one decimal point in any format 
tieia. If a decimal point is not specified in the format field, the 
number is rounded to the nearest integer and printed without any 
decimal places. 

When a decimal point is specified, the number of digits preceding the 
ctecimal point (including the minus sign, if the number is negative) 
must not exceed the number of pound signs before the decimal point. If 
there are too many digits an overflow occurs and the field is filled 
With asterisks ('*') . 

A comma (',') allows placing of commas in numeric fields. The position 
of the comma in the format list indicates where the commas appears in 
a printed number. Only commas within a number are printed. Unused 
commas to the left of the first digit appear as the filler character. 
At least one pound sign must precede the first comma in a field. 

If commas are specified in a field and the number is negative, then a 
minus sign is printed as the first character even if the character 
position is specified as a comma. 

FIELD EXPRESSION RESULl* COMMENT 



*|*| -'} -0.1 Leading zero added 

llll ^ 1-0 Trailing zero added 

!!f "^92-^ "^°^ Rounded to no decimal places 

III: 10 10. Decimal point added 

*fff 1 $1 Leading dollar sign 

#### -1000 **** Overflow because 4 digits and 

minus sign don't fit in field 

A dollar sign ('$') symbol shows that a dollar sign will be printed in 
the number. If the dollar sign is to float (always be placed before 
the number), specify at least one. pound sign before the dollar sign 
If a dollar sign is specified without a leading pound sign, the dollar 
sign is printed in the position shown in the format field. If commas 
and/or a plus or minus sign is specified in a format field with a 
dollar sign, the program prints a comma or sign before the dollar sicin 
The four up arrows or carets symbol is used to specify that the the 
number xs to be printed in E format (scientific notation) . A pound 
sign must be used in addition to the four up arrows to specify the 
field width. The arrows can appear either before or after the pound 
sign in the format field. Four carats must be specified when a number 
IS to be printed in £ format. If more than one but fewer than four 
carats are specified, a syntax error results. If more than four carats 
are specified only the first four are used. The fifth carat is 
interpreted as a no .text symbol. An equal sign ('=') is used to 
center a string in a field. The field width is specified by the number 
of characters (pound sign and =) in the format field. If the string 
contains fewer characters than the field width, the string is centered 
in the field. If the string contains more characters that can be fit 
into the field, then the rightmost characters are truncated and the 
string fills the entire field. A greater than sign ('>') is used to 



right justify a string in a field. 

5 X=32: Y=100.23: AS^-TEST" 
10 PRINT USING "$##.## "/IS.aS^X/Y 
20 PRINT USING "###>#"; "CBM",A$ 

When this is RUN, the following output appears on the screen: 

S13.25 $32.00 $***** 
CBM TEST 

$***** is printed instead of Y because Y has 5 digits, which exceeds 
the format specification. The second line asks for the strings to be 
right justified, which they are.. 

PDDEF - Redefine PRINT USING symbols 

PUDEF de fi nit ion_st ring 

PUDEF allows redefinition of up to 4 symbols in the PRINT USING 
statement. Blanks, commas, decimal points, and dollar signs can be 
changed into some other character by placing the new character in the 
correct position in the PUDEF definition_string. 

Position 1 is the filler character. The default is a space character. 
Place another character here to be used instead of spaces. Similarly, 

Position 2 is the comma character. Default is a comma. 
Position 3 is the decimal point. 
Position 4 is the dollar sign. 

. 10 PUDEF "*" PRINTS * in t'he place of blanks. 
20 PUDEF " @" PRINTS @ in place of commas. 

Q^T - [*** UNIMPLEMENTED ***] 

RCIJt - Get the current screen color 

RCLR (source) 

■ ■» 

[*** CURRENTLY UNIMPLEMENTED ***] 

This function returns the color assigned to source as an number in the 
range of 0-15. The color sources are: 

= background 

1 = foreground 

2 = multicolor 1 

3 == multicolor 2 

4 - border 

5 - highlight color 

ROOT - Get the current position or color of the pixel cursor 

ROOT (source) 
[*** CURRENTLY UNIMPLEMENTED ***] 
This function returns information about the current pixel location. 

= current X position 

1 - current Y position 



2 = color index 

READ - Read data from DATA statements 

READ variable_list 

READ statements are used along with DATA statements. READ statements 
read data from DATA statements into variables, just like an INPUT 
statement reads data typed by the user. READ statements can be used 
in direct or program mode, but DATA statements must be in a program. 

The variable types in the variable_list must match the type of DATA 
being read, or a 'TYPE MISMATCH', error is reported. If there are 
insufficent data m the program's DATA statements to satisfy all of 
the variables xn the READ statement, an 'OUT OF DATA' error is reported. 

The computer maintains a pointer to the next DATA item to be read by 
a READ statement. Initially this pointer points to the beginning of 
the program. As each variable in a READ statement is filled, the 
computer moves the DATA pointer to the next DATA item. If all of a 
READ statement's variables are filled before all of the data has been 
read from a DATA statement, the next READ statement will begin reading 
data at the point where the previous READ stopped. 

The DATA pointer can be changed by the RESTORE command. It can be 
reset back to the beginning of the program, or pointed to a specific 
line number. See RESTORE. f^-^.^^*, 

10 DATA 100, 200, FRED, "HELLO, MOM", , 3.14, ABC123, -1.7E-9 

30 READ NAME$, MSG$, NULL$ 
40 READ PI, JUNK$, S 
50 RESTORE 

RECORD - Specify a relative disk file record number 

RECORD #logical_channel_^number, record [,byte] 

This command allows you to access any part of any record in a RELative 
type disk file. If the byte parameter is omitted, the access pointer 
IS pointed at the first byte of the specified record number. 

Before you can use RECORD, you must OPEN a file. See OPEN and DOPEN 
for instructions. Also refer to your DOS manual for an explanation of 
Kbiiative type files . 

10 INPUT "ENTER RELATIVE FILENAME: ",F$ get name of existina file 
20 D0PEN#1, (F$),L: PRINT DS$ Ipen it&dilpitySisk status 

30 R=l: INPUT "ENTER RECORD NUMBER: ",R get a record nu^er 

50 t^rApn^^^T^^ ^^^^ <RETURN): ",B get byte number, if any 
In ?rmSS5T A^^i^ position file pointer 

fn ^^M^*i;S?^^ ^^^^ the record 

70 PRINT REC$ display the record 

80 PRINT "CONTINUE? (Y/N) " 
90 GETKEY A$: IF A$="Y" THEN 30 
100 DCL0SE#1 Close the file ■ 



REM 



Place an explanatory remark or conmient in a program 

REM plain text message 



The REMark command is just a way to leave a note to whomever is 
reading a LISTmg of the program. It might explain a section of the 



program, give information about the author, etc. 

REM statements in no way effect the operation of the program, except 
to add length to it (and therefore slow it down a little) - No other 
executable statement can follow a REMark on the same line. 

10 REM THIS PROGRAM WAS WRITTEN ON 2/14/91 BY F.BOWEN 

20 REM SAMPLE PROGRAM 

30 : - . 

40 DIR :REM DISPLAY THE BISK DIRECTORY 

50 LIST "SAMPLE PROGRAM" :REM DISPLAY THIS PROGRAM 

60 END 

EENAME - Rename a disk file 

RENAME "oldname" TO "newname" [,Ddrive] [<0N( ,>Udevice] 

The RENAME command changes the name of a file in the disk directory. 
Pattern matching is not allowed, and "newname" must be a valid filename 
that does not already exist on the disk. The file being renamed does 
not need to be open, 

RENAME "TEST" TO "FINALTEST" 

RENAME (OLDS) TO (OLD$+" .OLD") ON U(DEV) 

RENUMBER - Renumber the lines of a BASIC program 

RENUMBER [new_starting_line [/{increment] [, old_starting_line] ] ] 

Renumber is used to resec[uence the line numbers of a BASIC program in 
memory- All or part of a program can be renumbered. The RENUMBER 
command first scans the program to make sure all the line numbers 
referenced in commands (such as GOTO, GOSUB, TRAP, etc.) exist, that 
new line numbers are in the legal range, and that changing the program 
wJbld not overflow the available memory. An 'UNRESOLVED REFERENCE', 
'LINE NUMBER TOO LARGE', or 'OUT OF MEMORY' error is reported- if 
there's a problem, and RENUMBER is automatically canceled without 
having changed anything. 

If the program passes all the checks, RENUMBER changes the specified 
line numbers and updates all references to -the old numbers throughout 
the program and relinks the program. 

The new_starting_line is the number of the first line in the program 
after renumbering. It defaults to 10. The increment is the spacing 
between line numbers (eg., 10, 20, 30 would mean an increment of 10). 
It also defaults to 10. The old starting_line is the line number in 
the program where you want renumbering to begin. 

RENUMBER can be used in direct (edit) mode only. Note that line number 
zero (0) is a valid line number. 

RENUMBER Renumbers the entire program. After 

renumbering, the first line will be 10, 
the second 20, etc. through the end 
of the program 

RENUMBER ,1 Renumbers the entire program as above, 

but in increments of one. The first 
line will be 10, the second 11, etc. 

RENUMBER 100, 5, ,80 Starting at line 80, renumbers the 

program. Line 80 becomes line 100, 
and lines after that are numbered in 



increments of 5, through the end of 
the program. 

RENUMBER ,,65 Starting at line 65, renumbers lines 

in increments of 10/ starting at line 
10 through the rest of the program. 

RESTORE " Position READ pointer at specific DATA statement 

RESTORE [line] 

The computer maintains a pointer to the next DATA item to be read by 
a READ statement. Initially this pointer points to the beginning of 
the program. The DATA pointer can be changed by the RESTORE command. ■ 

Using RESTORE without Specifying a line number will reset the DATA 
poxnter back to the beginning of the program. If a line number is 
specified, the DATA pointer is pointed to that line. The line does 
not have to contain a DATA statement. When the computer executes the 
next READ statement, it will look for the next DATA item starting at 
the line the DATA pointer is at. 

See the READ command an example. 

RESUME - Resimie program execution after error TRAP 

RESUME [ line 1 NEXT] 

Used to return to execution after TRAPping an error. If a line number 
is given, the computer perforins a 'GOTO line' and resumes execution at 
that line. RESUME NEXT resumes execution at the statement following 
the one that cause the error. RESUME without any parameters will 
resume execution at the statement that cause the error. 

If the computer encounters a RESUME statement outside of a TRAP routine 
or if a TRAP was not in effect a 'CAN'T RESUME' error is reported. 
RESUME can only be used in program mode. 

10 TRAP 90 

20 FOR 1^-5 TO 5 

30 PRINT 5/1 

40 NEXT 

50 END 

60 : 

90 PRINT ERR$ (ER) : RESUME NEXT 

t 

RETURN - Return from, subroutine or event handler 

RETURN 

This statement is associated with the GOSUB (GO SUBroutine) statement 
When a subroutine is called by a GOSUB statement, the computer 
remembers where it's at before it calls the subroutine. When the 
computer encounters a RETURN statement, it returns to the place it 
last encountered a GOSUB and continues with the next statement. 

If there wasn't a previous GOSUB, then a 'RETURN WITHOUT GOSUB' error 
is reported. 

RETURN is also used by event handlers, set up by the COLLISION 
command. See COLLISION. 



RGR - Get the current graphic mode 

RGR CO) 

[*** CURRENTLY UNIMPLEMENTED ***] 

This function returns current graphic mode, A result of zero means 
the display is text, a non-zero result means it's graphic. 

RIGHT$ - Get the rightmost characters of a string 

RIGHTS (string, count) 

This function returns a string containing the rightmost 'count' number, 
of characters of the string expression. Count is an numeric 
expression in the range (0-235) . If count is greater than the length 
of the string, the entire string will be returned. If count is zero, 
a null (empty) string will be returned. 

A$ = RIGHT$("123ABC",3) Result is A$="ABC" 

RMOnSE - Get the mouse position and button status 

RMOUSE exposition [,Yposition [,button]]] 

X, ^position = current position of mouse pointer sprite 
Button ~ current status of mouse buttons 

= no button 

1 = right button 

128 = left button 

129 = both buttons 

RMOUSE is a command which retrieves a mouse' s current position and 
the state of its buttons, and places this information into the 
St^ecified numeric variables. If a mouse is not installed, "-i" is 
returned for all variables. If both ports are enabled, buttons from 
each port are merged. Use the MOUSE command to turn a mouse on or off. 

10 MOUSE ON, 2, 1 Turn mouse on, port 2, sprite 1 

20 DO Begin loop 

30 RMOUSE X, Y, B Get mouse position & buttons 

40 PRINTUSING"### •';X,Y,B Show " •• " 

50 LOOP UNTIL B=129 Loop until user presses both buttons 

60 MOUSE OFF Turn mouse off 

t 

RND - Get a pseudo-random nuiaber 

RND (type) 

The RND function returns a pseudo RaNDom number between and 1 . The 
random sequence returned is determined by the type parameter: 

type = Returns a random number based upon the system clock. 

type < Negative numbers "seed" the random number generator, 
defining a new but reproducible random sequence, 

type > Positive numbers draw the next random number from the 
sequence defined by the last "seed" value. 

This lets a programmer use a reproducible sequence while debugging 
(fixing) a program, so that random errors can be easily reproduced. 
Once the program has been fixed, it can be "seeded" such that a random 



sequence is used every time the program is run. 

10 DO 

20 INPUT "SEED"; S 

30 IF S'-O THEN END 

4 FOR 1=1 TO 5 

50 PRINT INT{RND(1)*6)+1, INT(RND{1) *6) +1 

60 NEXT 

70 LOOP 

The above program will demonstrate the results of seeding the random 
number generator. It lets you specify a positive or negative seed 
value, and then prints the first 5 random pairs of that sequence. 
Enter a zero to end the program.. The calculations in line 50 make the 
random numbers be integers from 1 to 6, like dice. Type in a negative 
number to start a new sequence, and a positive number to "roll" more 
dice from that sequence. Every time you enter "-1", for example, you 
will roll the same numbers; 

first roll 2 and 6 

second 6 and 1 

third 1 and 1 

fourth 1 and 4 

fifth 5 and 5 

Games and statistical programs should use RND(O) for true randomness, 
or seed the generator with a random number, such as RND(-TI) , 

The general form for getting random integers using RKD is; 

INTC RND(O) * MAX ) + 1 

where MAX is the highest number you can get. This gives you numbers 
as low as 1 and as high as MAX. For dice, MAX is 6 (or 12 if you want 
to simulate rolling two die ac once) . For cards, MAX is 52 . 

INK RND(O) * 16) 

This form will return integers from zero to 15, Which is useful for 
generating random color values, for example. 

KREG - Get register data after a SYS call 

RREG [a_reg] [, [x_r€g] [, [y_regj [, [2_reg] [, status] ] ] ] 

Following a SYS call, the RREG command retrieves the contents of the 
microprocessor's registers and puts them into the specif'ied numeric 
variables. See the sample program at SYS. 

RSPCOLOR - Get multicolor sprite colors 

RSPCOLOR (multicolor*) 

Returns the current colors for multicolor sprites. Color values range 
from 0-15. Use RSPRITE function to get the foreground sprite color. 

multicolor* = 1 gets multicolor #1 
multicolor* = 2 gets multicolor *2 

See SPRITE and SPRCOLOR. 

RSPPOS — Get the location and speed of a sprite 



RSPPOS (sprite, parameter) 

The RSPPOS function returns the current X or Y position of a sprite 
and its speed, set by the MOVSPR command. A sprite does not have to 
be on to use RSPPOS. The sprite number must be in the range of 0-7, 
and the parameter is: 

to get current X position 

1 to get current Y position 

2 to get current speed (0-255) 

RSPRITE - Get information about a sprite 

RSPRITE (sprite, parameter) 

The RSPRITE function returns the current state of a sprite, set by 
the SPRITE command. The sprite number must be in the range of 0-7, 
and the parameter is: 

to see if it's turned on (l)=yes <0)=no 

1 to get sprite foreground color (0-15) 

2 to get priority over background (l)=yes (0)=no 

3 to get X-expansion factor (i)=yes (O)-no 

4 to get Y-expansion factor (i)=yes (0)=no 

5 to get multicolor factor (i)=yes (0)=no 

RUN - execute BASIC program 

RUN [line #] 

RUN "filename" [,Ddrive] E<ON| ,>Udevice] 

RUN executes the BASIC program that is currently in memory. The 
program has to be LOADed (DLOAD) or manually typed in before it can 
be executed. ^ If a line number is specified, execution begins at that 
I'Jie. If a filename is specified, the program is automatically loaded 
from disk into memory and executed. RUN can be used in a program. 

RUN clears all variables and open channels (but it does NOT properly 
close open disk write files- used DCLOSE or DCLEAR beforehand) . RUN 
also resets the runtime stack pointer (clears GOSUB & FOR/NEXT stacks), 
the DATA pointer, and the PRINT USING characters. To start a program 
without initializing everything, use GOTO. 

RUN Starts the program at the first line. 

RUN 100 Starts the program at line 100. 
RUN "TEST" Loads the program TEST from the default system 
disk and starts the program at the first line. 

BHINDOH - Get information about the current text window 

RWINDOW (parameter) 

This is a function that returns information about the current console 
text display. The parameter is specified as: 

to get the maximum line # in the current window 

1 to get the maximum column # in the current window 

2 to get the screen size, either 40 or 80 columns 

SAVE - Save a BASIC program in memory to disk 

SAVE "[ [@1 drive: 1 filename" [, device number] 



Thxs command copies a BASIC program in the computer's BASIC memory 
area xnto a PRoGram-type disk file. If the file already exists, 
the program is NOT stored and the error message 'FILE EXISTS' is 
reported. If the filename is preceded with an '@0:', then if the file 
®^^S^^ ^^ ^^^^ ^® replaced by the program in memory. Because of some 
problems wxth the 'save-with-replace' option on older disk drives, 
■using thxs option is not recommended if you do not know what disk drive 
xs being used (DELETE the file before SAVEing) . Pattern matching is 
not allowed. In the case of dual drive systems, the drive number must 
be part of the filename. 

Use the VERIFY or DVERIFY command to compare the program in memory with 
a program on dxsk. To save a binary program, use the BBAVE command. 

SAVE "myprogram" Creates the PRG-type file MYPROGRAM 

on the default system disk and copies 
the BASIC program in memory into it. 

SAVE "@0: myprogram" Replaces the PRG-type file MYPROGRAM 

with a new version of MYPROGRAM. If 
MYPROGRAM doesn't exist, it's created. 

SAVE F$,9 Saves a program whose name is in F$ 

on disk unit 9. 

SCALE - Set the logical dimension of the graphic screen 

[*** NOT YET IMPLEMENTED ***] 

SCNCI4R - Clear a text or graphic screen 

SCNCLR Tcolor] 

This command will clear the current text window if [color] omitted, 
otherwxse xt wxll clear the current graphic screen using the given 
color value. See also SCREEN CLR. 

■ SCNCLR Clears the text screen. If a window is defined, 

it clears only the window" area. 

Clears the current graphic screen with color 0. 



SCNCLR 



SCRATCH - Delete files from disk directory 

Recover accidentally deleted files ' 

SCRATCH "filespec" CDdrive] [<0N| ,>Udevice3 [#Ri 

SCRATCH, ERASE, or DELETE are different names of the same command. 
They are used to delete a file from a disk directory, or optionally to 
recover xf possxble an accidentally deleted file. The diskette must 
not be write protected', or a 'WRITE PROTECT ON' error is reported. 

WARNING: Deleting a file will destroy all existing data in that 
file. Be extremely careful if you are using pattern matching, which 
can delete any or all files. In direct mode, you are asked to confirm 
what you are doing with 'ARE YOU SURE?'. Type 'Y' and press return to 
proceed, or TYPE ANY OTHER CHARACTER AND PRESS RETURN TO CANCEL the 
command. In program mode there is no confirmation prompt. 

Upon completion, in direct mode only, the computer will display the 
number of files deleted. 



Refer to your disk manual for other details. Different disk drives 
implement slightly different pattern matching rules or support features 
such a specially protected files. 

If the 'R'ecover option is present and the DOS supports it, a deleted 
file can be recovered if nothing else has been written to the diskette 
since the file was accidentally deleted. You will still be asked to 
confirm the operation, and upon completion the computer will display 
the number of files restored. 

SCRATCH **oldfile" Deletes the file OLDFILE from the disk 

in the default system drive. 

SCRATCH "file.*" Deletes ail files beginning with FILE. 

SCRATCH {F$), U(DD) Deletes the file whose name is in F$ 

from the disk in device DD. 

SCRATCH "saveme" ,R Attempt to recover the program SAVEME. 

SCREEN - Graphic command 

The SCREEN commcind is used to initiate a graphic command. It always 
precedes another command word which identifies the graphic operation 
to be performed: 

SCREEN CLR - Set graphic screen color 

SCREEN CLR colorl 

Clears (erases) the currently opened graphic screen using the given 
color value. Use SCNCLR to clear a text screen. See also SCNCLR. 

SCREEN DEF - Define a graphic screen 

J SCREEN DEF screen*, width, height, depth 

screen* 0-1 

width 0=320, 1=640, 2'=1280 

height 0=200, 1=400 

depth 1-8 bitpianes (2-256 colors) 

Defines a logical screen (nximbered or 1), specifies its size and 
how many colors (bitpianes) it has. It does not allow access to the 
screen and it does not display the screen. The screen must be defined 
before it is opened for viewing and/or drawing to. 

SCREEN SET - Set draw and view screens * 

SCREEN SET DrawScreen#, ViewScreen# 

draw screen # 0-1 
view screen * 0-1 

This command specifies which logical screen is to be viewed and 
which logical screen is to be accessed by the various draw commands. 
The screen must be defined and opened first. Both the draw and the 
view screen can be, and usually are, the same logical screen. For 
double buffering, they are different. 

SCREEN OPEN - Open a screen for access 

SCREEN OPEN screen* [, error_variable j 

screen* 0-1 



error_variable [*** NOT YET IMPLEMENTED ***] 

This command actually sets up the screen and allocates the necessary 
memory for it. If it's the view screen it will be displayed. If it's 
the draw screen, it can now be drawn to. If there is not enough 
memory for the screen, 'NO GRAPHICS AREA' is reported and the screen 
is not opened. 



SCREEN CLOSE 



- Close a screen 



SCREEN CLOSE screen* 

screen* 0-1 



This command closes a logical screen, ending access to it by the 
draw commands if it's the draw screen and restoring the text screen 
if it's the view screen. SCREEN CLOSE deallocates any memory reserved 
for the screen. 



SAMPLE GRAPHIC PROGRAM: 



1 TRAP 170 

10 GRAPHIC CLR 

20 SCREEN DEF 1,0,0^2 

30 SCREEN OPEN 1 

40 PALETTE 1,0, 0, 0, 

50 PALETTE 1,1, 15, 0, 

55 PALETTE 1,2, 0, 0,15 

60 PALETTE 1,3, 0,15, 

70 SCREEN SET 1,1 

SO SCNCLR 

90 BORDER 
100 PEN 0,1 

110 LINE 100,100, 150,150 » 
120 PEN 0,2 

130 BOX 50,50, 50,80, 80,50, 80,80 
140 PEN 0,3 

150 CHAR 25,50, 1,1,2, "WORDS" 
160 SLEEP 5 
170 SCREEN CLOSE 1 
180 PALETTE RESTORE " 
190 BORDER 6 
200 END 



color 





= 


black 


color 


1 


ss 


red 


color 


2 


= 


blue 


color 


3 


= 


green 



in case of error want text screen 

initialize graphics 

define a 320x200x2 graphic screen 

open it 

define screen 1, 

define screen 1, 

define screen 1, 

define screen 1, 

make it the view screen 

clear screen with palette color 

set border color to color 

make draw pen = color 1 (red) 

draw a diagonal red line 

make draw pen = color 2 (blue) 

draw a blue box 

make draw pen = color 3 (green) 

draw green text 

pause for 5 seconds 

close graphic, get text screen 

restore normal system colors 

restore normal border color 



SET - Set various system parameters 

i 

The SET command is used to set a system parameter. It always 
precedes another command word which identifies the parameter to be 
changed: 



SET DEF 



- Set default system disk drive 
SET DEF device 



The BASIC DOS commands default to disk unit 8. Use SET DEF to change 
which device these commands default to. This command does not renumber 
a disk device, use SET DISK for that. Commands which specify a device 
will still access the device they specified. A program can be made 
more "user friendly" by either not specifying a drive (thus using the 
user's perf erred drive) or by specifying device 1. Device number 1 
means "use the system aefault drive, whatever its number is," 



10 DIR 
20 DIR Ul 



gets directory of device 8 
gets directory of device 8 



30 DIR UIO gets directory of device 10 

40 SET DEF 10 change the default drive to unit 10 

50 DIR gets directory of device 10 

60 DIR Ul gets directory of device 10 

70 DIR U8 gets directory of device 8 

SET DISK - Change a disk device number 

SET DISK oldnumber TO newnuraber 

Use this command to renumber (change) a disk drive's unit number. 
Not all drives can be renumbered- refer to your disk drive manual 
for details. This command sends to the disk's command channel the 
conventional CBM serial disk drive "M-W" command. See also the 
DISK command, which lets you send any command to a disk drive. 

SET DISK 8 TO 10 Change unit 8's number to 10 

Because the built-in C64pX drives always take precedence over serial 
bus drives, this is one way to get the built-in drive "out of the way" 
so that you can access a serial bus drive #8. 

SGN - Get the sign of a number 

SGN (expression) 

The SiGN function returns the sign of a numeric expression as follows: 

If the expression is < (negative) returns -1 

If the expression is = (zero) returns 

If the expression is > (positive) .... returns 1 

SIN - Sine function 
> SIN (expression) 

This function returns the sine of X, where X is an angle measured 
in radians. . The result is in the range -1 to 1. 

X =^IN<pi/4) Result is X=0.707106781 

To get the sine of an angle measured in degrees, multiply the nxameric 
expression by pi/180, 

SLEEP - Pause program execution of a specified period of , time 

SLEEP seconds 
Temporarily suspends execution of your prograun for 1 to 65535 seconds. 

SLOW - Set system speed to 1.02MHz 

SLOW is used primarily to directly access "slow mode only" devices 
such as the SID sound chips. FAST is the default system speed. 

SOOND - Produce sound effects 

SOUND V, f, d [,[dir] t,[m] [,[s] [, [w] E,p] ]1]1 

V = voice (1-6) 

f = frequency (0-65535) 



d = duration (0-32767) 

dir - step direction (0(up), 1 (down) , or 2 (oscillate) ) default=0 

m - nun frequency (0-65535) dSfiuS=n 



s = sweep (0-65S35) default-0 

w -- waveform (O^'triangle, l=saw, 2=square,3-noise) default-2 
P - pulse width (0-4095) 50% duty cycle=deftult=2048 

Ind m?,'i^n.T^^^^ ^^^t H^^ "^"^ ^^^^ "^y ^° =^«^te sound effects 
se?p^ ihf ^9^^^' ^^^ fi"t three parameters are required to 
select the voice, frequency, and duration of the tone; The 
durat:Lon xs specified in "jiffies" (60 jiffies = 1 second) . 

Optionally, you can specify a waveform and, for square waves the 
pulse width. The SOUND command .can sweep, k voice throughlserils 
^5h 5^^^^^'^r^^'^ frequencies. The direction of the swiepf mini^L 
thf ZZT" ^^^^^"^i^s can be programmed. If time expires h^f^T 
frSoSencv ±1 r^^^A.H^H ?<^"^^?tops. If the minimum or maximum 
rrequency is reached before time expires, the sound repeats. 

^Sf P^P^ramming details, refer to the SXD hardware documentation tJse 
TP^X^^"^^ command to change the volume of the sound. No^ethl? thS 
TEMPO command affects PLAY strings only, not SOUND effects! 

FREQout - ( f * 0.0596 ) Hz 
PWout =( p / 40.95 ) % 

fof a'^wide v^Si^?/^?^""^^^"^ separately and played simultaneously 
nt%Tr Z ^?^i«ty of sound effects. Once a sound effect is initiated 

SOUND 1, 7382, 60 




SOUND 2, 7382, 336, 0, 1678, 17 

Using voice 3, maJce a neat sound using an oscillating sweep (dir=21 
and a sawtooth waveform (w=i) for 3 seconds (t-180) V ' lciir-2) 

SOUND 3, 5000, 180, 2, 3000, 500, 1 



SPC - Space PRINT output 

SPC (number) 



The SPaCe function is used to format PRINTed data to the screen 

^lc?SnS^^^; °^ ^ 5^^?cc ^^ specifies the number ol spaces lo be ' 

lollow SPc''°LL*'-f^^^- "" s^"i<=°l<=" ('-•') is always assumed to 
roiiow SPC, even if it appears at the end of a print line. 

InH H^^u^"''^^^?'' works a little differently on screen, printer, 
and disk output. On the screen, SPC skips over characters alr4adv 

Tn pr?nterr"l/l?H''/'."°^ ^""^ ""^" "^^^ printed an^d^Ik tm'', 
will it^^n^=;,-i5i?^ ^^V character on a line is skipped, the printer 
will automatically perform a carriage return and linefeed. 



PRINT ''123";SPC{3);''456" Displays '123 456' 

PRINT "X";SPC(5) :PRINT"X" Displays 'X X' 

See also the TAB function. A better way to fonnat PRINT output is 
with PRINT USING. 

SPRCOLOR - Set multicolor sprite colors 

SPRCOLOR [sprite_mcll [, sprite_mc2] 

Use the SPRITE command to set up a multicolor sprite, arid used SPRCOLOR 
to set the additional colors. Note that these colors are common to all 
multicolor sprites. The color values must be in the range (0-15) . Use 
the RSPCOLOR function to get the current multicolor sprite colors, and 
RSPRITE to get the current sprite foreground color. 

SPRDEF - Define a sprite pattern 

[*** NOT EXPECTED TO BE IMPLEMENTED ***] 

SPRITE - Turn a sprite on or off, and set its characteristics 

SPRITE number [, [on] [, [fgnd] [, [priority] [, [x_expl [, [y_exp] [,mode] ] ] ] ] ] 

The SPRITE command allows you set all of the characteristics of a 
sprite. Use the MOVSPR command to position it or set it in motion. 
Use the SPRCOLOR to set the multicolor sprite colors, if you are 
using multicolor sprites. 

All the parameters except the sprite number are optional. If you 
don't specify a parameter then it won't be changed. 

number ^ sprite number (0-7) 

on = enable (1) or disable (0) 
color = sprite foreground color (O-IS) 
priority= sprite to display data priority: 

means sprite goes over screen data 

1 means sprite goes under screen data 
x,y-exp = sprite expansion on (1) or off (0) 

mode = sprite mode : 

high resolution 

1 multicolor 

» 

The SPRITE command does not define a sprite. The sprite definitions 
must be loaded into the sprite area first ($600-S7FF) . Use the 
BLOAD and BSAVE commands. [*** THIS MAY CHANGE ***] A sprite is 
24 pixels wide and 21 pixels high. Each sprite definition requires 
63 ($40 hex) bytes: 



$600 


Sprite 





definition 


$640 


Sprite 


1 


definition 


$680 


Sprite 


2 


definition 


$6C0 


Sprite 


3 


definition 


$700 


Sprite 


4 


definition 


$740, 


Sprite 


5 


definition 


$780 


Sprite 


6 


definition 


$7C0 


Sprite 


7 


definition 



Use the RSPRITE function to read a sprite's characteristics, or the 
RSPPOS function to read a sprite's position. The RSPCOLOR function 
is used to get the current multicolor sprite colors. 



2^ ^pS^it^?''^?^ i data",P(dec{"640")) Load sprite I's definition 

4S SPrIaV i' 2 '^° ?^^ ^^ ^^ top-leftmost corner 

50 SPRITE 9 17 ^"Pi' sprite 1 definition to 2 

60 MOVSpI 2' k'-X) -ioa Turn on sprite 2 make it yellow 

SPRSAV - Copy a sprite definition 

SPRSAV source, destination 

?n?^^^^®^'^*?"^^"'^ to copy a sprite's data (shape) to another sprite or - 
t^l^^t J"-"^ variable, or copy a shape from a string variablS into a 
sprite You can have many different sprite shapes in memory at one 
time, all stored m strings. This makes it possible to animate 

llltl^i't^^"" ^""^'^ 5^ ^^'^^^^ "flipping through" shapes, u^Tng each 
shape like a frame from a movie film. 

SPRSAV 0, A$ copy the data (shape) of sprite into A$ 
SPRSAV AS, 2 copy the data (shape) in A$ into sprite 2 
SPRSAV 1, 2 copy the data (shape) in sprite 1 to sprite 2 

STASH - (see the DMA command) 

SQR - Square root function 

SQR (number) 

exorJs?^^°%^f n"""^ -^^ °^ theSQuare Root of the given numeric 
^Trflrfr S/t^xt^tSv?''"'^'''-'' expression must not be negative or an 
'ILLEGAL QUANTITY' error is reported. 

A = -SORdO) Result is A = 3.16227766 
STEP - See FOR/NEXT/STEP 

STOP - Halt program execution • 

STOP 

When STOP is executed, the computer immediately stops running the 
program and reports 'BREAK IN LINE xx' . No variablSs are cllared 
and files are not closed, 

I?iL''?r"t"5 ^^ usually used while debugging (fixing) a BASIC program, 
v^riLtL ^nH^'"' r°? ?^ ^ specific place, examine variables, chSnge 
variables, and restart the program where it was halted (see CONTinue 
command) or some other line (see GOTO). In many cases, you can even 
change the program and use GOTO to resume execution with variables 
and open channels intact. ^^«wx^a ^ 

SWAP - {see the DMA coimnand) 



STR$ - Get the string representaion of a number 

STR$ (nioiober) 

The STRing function returns a string identical to PRINT'S output 
of the given numeric expression. See PRINT for details regarding 
the format of numeric output. STR$ is the opposite of VAL, 

AS = STR$(123) Result is A$ = " 123"- 

A$ = STRS (-123) Result is A$ == "-123" 
A$ = STRS (.009) Result is A$ = " 9E-03" 

SYS - Call a ROM routine or user machine language routine 

SYS address [, [a] [, [x] [, [y] l, M ies] ]]] 

This statement performs a call to a machine language routine at the 
specified address (range 0-65335, $OO00-$FEFF) in a memory bank set 
up previously by the BANK command* 

The microprocessor's registers are loaded with the values specified 
in the parameters following the address (if given) and a JSR 
(Jump SubRoutine) instruction is performed. When the called routine 
ends with an RTS (ReTurn from Subroutine), the microprocessor's 
registers are saved and control is returned to the BASIC program. 
The microprocessor's registers can be examined with the RREG command. 

Because this command instructs the computer's microprocessor (CPU) 
to perform something, extreme care should be taken in its use. It 
can easily crash the computer if you do something wrong (press the 
reset button to reboot) . Also see the BOOT SYS command. ■ 

BANK 128: SYS DEC("FF5C") Call the Kernel's PHOENIX routine. 

BANK 128: SYS DEC("FF81") Reset the Screen Editor 
> 

10 BANK 128 

20 BLOAD"user routine",? (dec("1800") ) Load a user routine 

30 SYS DEC("1'^00"), areg, xreg Call it with args in A and X 

40 RREG areg, xreg, , , sreg Get args back in A, X, and S ' 

50 carry = (sreg AND 1) Get carry flag from S 

60 PRINT "ACCUMULATOR = ";HEX$(areg) Display registers 

60 PRINT "X REGISTER = ";HEX$(xreg) 

60 PRINT "CARRY FLAG =* "; carry 

See the USR function for another way to call machine language routines. 

TAB - Space PRINT output 

TAB (number) 

The TAB function is used to format PRINTed data to the screen, a 
printer, or a file. It's primarily for screen text output, moving 
the cursor to the specified column (plus one) as long as the current 
print position is not already beyond that point (for example, if the 
current print position is the first column, TAB(l) would print 
subsequent text beginning in column 2) . If the current print position 
is already beyond the column specified by the TAB function, nothing 
is done. For disk and printer output, TAB works exactly like the SPC 
function (see SPC) . 

A semicolon (' ;') is always assumed to follow TAB, even if it appears 
at the end of a print line. 



PRINT "TEXT"; TAB (10); "HERE" Result is 'TEXT HERE' 
PRINT "TEXT" ;SPC (10); "HERE" Result is 'TEXT HERE' 

The aiove examples illustrate the difference between TAB and SPC. See 

Irmt nliwr n^n^J'"''- / ^®5J®^ "^^.^^ ^?^^^ ^^^^T output is with 
rwp^To? ^ V, ° ^ confuse the TAB function with the TAB character, 
CHR5(9), which is used to format data using the programmable TAB stops, 

TAN - Tangent function 

TAN (expression) 

in'^rad^^S^^^'^TJ^^H'''''' ^he tangent of the numeric expression, measured 
^SJt^^nSf' ^^ ^^® ''^^''^^ overflows, TAN (pi/2) for example, an 
OVERFLOW error is reported. 

X = TAN(l) Result is X=l. 55740772 

To get the tangent of an angle measured in degrees, multiply the 
numeric expression by pi/180. ^ 

TEMPO - Set the tempo (speed) of a PIAY string 

TEMPO rate 

the P^? rnZt^H "'"t^'^^'^^I ^5^ ^^^?° f^P^^^» °^ ^"si<= playback by 
Th! H^I command. The rate determines the duration of a ihole note. 

foLulf is^ ""^ ' "^ "^ ^ "^°^'' ^"^ *^^^ ^^® ^^^t 2 seconds. The 

duration = 24/rate 

The higher the rate, the f astir the note. The range is (1-255) . 

THEN - See IF/THEN/ELSE 

TO - See FOR/NEXT/STEP. Also used as a subcommand. ' 

TRAP - Define an BASIC error handler 

TRAP Uine_number] 

When turned on, TRAP intercepts all BASIC execution err'or conditions 
except 'UNDEF'D STATEMENT ERROR'. Even the STOP key can br?R^ped! 

When an error occurs, BASIC saves the error's location, line number, 
and error number. If TRAP is not set, BASIC returns ti direct mode 
and displays the error message and line number. If TRAP is set 
BASIC performs a GOTO to the line number specified in the TRAP ' 
statement and continues executing. 

Your BASIC error handling routine can examine the error number. 
message, and the line number where the error occurred and determine 
the proper course of action. The system error words are: 

ER Error Number 

EL Error Line (line where the error occurred) 
ERR$() Error Message 

^£ ^f^^^t."^,' ^^®" ^ BASIC error did not occur. The error routine 
should check the disk status words, in case they were the cause of 



the error: 



DS Disk Error Number 
DS$ Disk Error Message 



Refer to the list of BASIC and Disk error messages in the appendix. 

Note that an error in your TRAP routine cannot be trapped. The 
RESUME statement can be used to resume execution- see-RESDME. 

TRAP with no line nxomber specified turns off error TRAPping. 

10 TRAP 90 enable trapping 
20 FOR I=-5 TO 5 r^ y 

■ 30 PRINT 5/1 error when I-Q 
40 NEXT 

50 TRAP tur. trapping off 

70 : 

90 PRINT ERR$ (ER) : RESUME NEXT error routine 

TROFF - Turn off trace mode 
TRON - Turn on trace mode 

TROFF 
TRON 

Trace mode is used while debugging (fixing) a BASIC program. TRON 
enables tracxng, and TROFF disables tracing. When the program is run 
and trace mode os on, the line number of the command that is being 
executed is displayed on the screen. If there are three commands on 
the line, the line number will be displayed three times, once each time 
one of the commands is executed. Trace mode lets you know what the 
computer is doing. 

T »ce mode works even when a graphic screen is being displayed, but 
the line number is still displayed on the text screen so you won't be 
able to see it until the graphic screen is turned off. If your program 
IS doing alot of PRINT statements, the display can seen a little 
confusing. 

Trace mode can be set in direct mode to trace the entire program, or 
it can be turned on and off from within your program to let you trace 
only selected portions of the program. 

Trace mode has no effect on commands entered in direct (edit) mode 
The NEW command disables trace mode, but RUN and CLR do r^ot. 

10 FOR I=-5 TO 5 

15 TRON 

20 PRINT 5/1 

25 TROFF 

30 NEXT 

TYPE - Display the contents of a sequential disk file 

TYPE "filename" [,Ddrive] [<, ION>Udevice] 

Use this command to print the contents of a PETSCII data file on 
the screen. The file must contain lines no longer than 255 
characters long and terminated by a return character (CHRS(13)) . 
Lines too long result in a 'STRING TOO LONG' error. 

TYPE "readme" display the contents of the README 



file on the screen 

The command sequence below will print the contents of the README file 
on a CBM serial Idus printer in upper/lower case mode. 

OPEN 4,4,7: CMD4 : TYPE"readnLe": CL0SE4 
UNTIL - See DO/LOOP/WHIEE/ONTII./EXIT 

USR — Call a user defined machine language function 

USR (expression) 

When this function is used, the program jumps to a machine language 
subroutine whose starting address must be POKEd into system memory 
(BANK. 128) at address 760 (low byte) and 761 (high byte), or $2F8 hex. 
The floating point value of the numeric expression is passed to the 
routine in the Floating point Accumulator (FACC) , and the value to 
be returned is taken from the FACC when the routine ends. 

If the USR vector is not set up prior to making the USR call, an 
'UNDEF'D FUNCTION' error is reported. The routine must be located 
in the system bank. The BANK command does not affect USR. 

Using this method of calling a machine language routine requires a 
fair amount of set up and a good knowledge of the lower level math 
routines built into BASIC. See the SYS command, which is more 
commonly used to call a machine language routine. 

The following program illustrates the basic steps required for 
installing a USR routine and calling it: 

10 BANK 128 ^ System bank for poke & load 

20 UV = DEC ("1800") Where my routine is 

30 BLOAD "my user routine",? (UV) Load my routine 

40 POKE DEC("2F8"), UV AND 253, UV / 256 Set up USR address 

50 X = USR (123) : PRINT X Call my routine with the 

the value 123, get back and 
print whatever my routine 
leaves in FACC 

The following program actually works. It points the USR vector to the 
BASIC math jump table entry for the routine which inverts the sign 
of the number in the FACC. Type in positive & negative numbers: 

10 BANK 128 System bank •for poke 

20 POKE DEC(*'2F8"), DEC ("33"), DEC("7F") Set up USR address 

30 DO: INPUT"SIGNED NUMBER"; N Get number input 

40 : PRINT USR(N) Display USR output 

50 : LOOP UNTIL N=0 End if user types zero 

USING - See PRINT USING 

VAL - Get the numerical value of a string 

VAL (string) 

The VALue function converts a string into a number. The conversion 
starts with the first character and ends at the end of the string or 
the first character that is not allowed in normal number input. 
Spaces are ignored. If the first character of the string is not a 
legal character, a zero is returned. 



The VAL function works the same way the INPUT and READ commands do* 
VAL is the opposite of STRS. 

X = VAL(" 123") Result is X = 123 
X = VAI.("-123") Result is X = -123 
X = VAL(" 9E-02") Result is X = .09 

VERIFY - Compare a. program or data in memory with a disk file 

VERIFY "filename" [,device_number [,relocate_flag] ] 

This command is just like a LOAD, command, except instead of putting 
the data read from a file into memory, the computer compares it to 
what is already in memory. If there's any difference at all a 
'VERIFY ERROR' is reported. 

The filename must be given, and. pattern matching may be used. In 
the case of dual drive systems, the drive number must be part of the 
filename. If a device number is given, the file is sought on that 
unit, which must be a disk drive. If a device number is not given, 
the default system drive is used. See also DVERIFY. 

Note: If the BASIC program in memory is not located at the same address 
as the version on disk was SAVEd from, the files will not match even if 
the program is otherwise identical . 

The relocate_flag is used to VERIFY binary files. If the relocate flag 
is present and non-zero, the file will be compared to memory starting 
at the address stored on disk when the file was SAVEd. The memory bank 
used is the bank given in the last BANK statement. The ending address 
is determined by the length of the disk file. The comparison halts 
on the first mismatch or at the end of the file. The area to be 
compared must be confined to the indicated memory bank. Do not use 
the relocate_flag to verify BASIC programs. See also BVERIFY. 

VERIFY "myprogram" 

Good: SEARCHING FOR O:myprogram Bad: SEARCHING FOR Ormyprogram 
VERIFYING VERIFYING ' 

OK - ?VERIFy ERROR 

VERIFY "PROG" Compares BASIC program in memory to file PROG 

on the default system disk. 
VERIFY FILES, DRV Compares program in memory to a program whose 

name is in the varicible F$ on the unit whose 

number is in DRV. t 

VERIFY "0:PROG",8 Compares memory to BASIC program PROG on unit 

8, drive-0, 

BANK 128 Compares a binary file into memory. The 

VERIFY "BIN", 8,1 address" used comes from the disk file, but you 

must specify the memory bank. 

VIEWPORT - [*** CURRENTLY UNIMPLEMENTED ***] 

VOL — Set audio volume level 

VOL volume 
[*** THIS COMMAND WILL CHANGE ***] 
This statement sets the volume level for SOUND and PLAY statements. 



VOLUME can be set from to 15, where 15 is the maximum volume A 
voiume of turns sound output off. VOLume affects all 3 voices 
Note that PLAY strings can change the volume, too. 

WAIT - Pause BASIC program until a memory state satisfied 

WAIT address, and_mask [,xor_mask3 

The WAIT statement causes program execution to be suspended until data 
at a specified memory location matches a given bit pattern It's used 
to pause your program until an event occurs. 

^o^^^'S"^ "^f^-^^ ?® 5" ^^° ^^^^® <5"^^ ^s a fire button or peripheral 
port change) , a hardware state (such as the raster position or RS232 
status), or memory change caused by an interrupt event (such as a 
jceyboard scan) . 

^o!fiSS^R.^ = nH^?«n^^^^^^i*'^^.'=^"*P''^^'^^° "^^ *^^2K> a memory location 
(U fe5533) and AND the value it got with the number in and mask (0-255) 

m?^ . iS zero, repeat the operation until the result is not 
zero. This is like the following BASIC instructions, but much faster: 

DO: result = PEEK (address) : LOOP UNTIL (result AND and_mask) <> 

"htSh-^fi^f^if ^^?/^^t^ yo« ^" WAlTing for is non-zero (a one or 

nigh state) . If you want to wait for a zero state (a "low" state), 
you need to use the xor_mask option to "flip" the bits of the result. 

Note that it's possible to "hang" your program indefinitely if the 
state you are waiting for never happens or you specify the wrona data 
Press the STOP and RESTORE keys at the same time to get control^back 

Be sure to use the BANK command before you tell the computer to WAIT, 
to specify which 64K memory bJnk the address is in. Note that a BANK 

^^f^f^^r^^^JV^^'^ i^2 *^:!-' ^ ^^^^ ^""^^^ ^ith the most significant 
r^L; ^i ?1^^^ be used to address an I/O location, such as the Vic chip. 
Refer to the system memory map for details. "-"J-F- 



10 BANK 128 

20 WAIT DEC(**D011") , 128 

10 BANK 128 

20 WAIT DEC("D011") , 128, 128 

10 BANK 128 

20 WAIT DEC("D3") , 1 

30 WAIT DEC("D3"), 2 

40 WAIT DEC("D3"), 4 

50 WAIT DEC("D3"), 8 



Wait for the VIC raster to be 
offscreen (want RC8 = 1) 

Wait for the VIC raster to be 
onscreen (want RC8 = 0) 

Wait for user to press shift 
Wait for user to press C= key 
Wait for user to press CTRL key 
Wait for user to press ALT key 



WHILE - See DO/LOOP/WHILE/UNTIL/EXIT 



miDTH - 



[*** CURRENTLY UN IMPLEMENTED ***] 



WINDOW - Set a text window 

' WINDOW left_column, top_row, right_column, bottom_row [, clear] 

This command defines a logical text screen window. All text I/O will 
,t 5?f ^"®^ ^? ^^^^ window. The row parameters must be in the range 
(u-^4 , and the column parameters must be in the range (0-79) for 
80-column screens or (0-39) for 40-coiumn screens. The parameters are 



always referenced to the physical screen (i.e., you cannot define a 
window within a window) . If the clear flag is given, the new window 
area will be cleared after it's set up. 

Use the RWINDOH function to get the current window size. 

You are responsible for saving and restoring screen data in all windows 
because the WINDOW command simply sets the window margins. The WINDOW 
command does not draw a border around a window. All color commands and 
screen modes (such as scroll disable, TAB stops, etc.) are global. 

Two consecutive "home" characters will reset the window definition 
back to the physical screen. 



WINDOW 0,0,39,24 
WINDOW 40,0,79,24 
WINDOW 0,0,79,12 
WINDOW 0,13,79,24 
WINDOW 20,6,59,12,1 



Define a window in 80-column mode 
that is the left half of the screen 

Define a window in 80-column mode 
that is the right half of the screen 

Define a window in SO-column mode 
that is the top half of the screen 

Define a window in 80-column mode 
that is the bottom half of the screen 

Define a window in 80-column mode in 
the center of the screen and clear it. 
The window is 12 characters high and 
40 characters wide. 



PRINT CHR$(19)CHR$(19); Reset the. window back to full screen 

in either" 40 or 80-column mode and put 
the cursor in top left corner. 

2"?R - Exclusive-Or function 

XOR (number, number) 

The XOR function returns a numeric value equal to the logical XOR of 
two numeric expressions, operating on the binary value of the unsigned 
16-bit integers in the range (0 to 65535)..., Numbers outside this 
range result in an 'ILLEGAL QUANTITY' error. 



X = XOR(4,12) 
X = X0R(2,12) 



Result is X= 8 
Result is X=«14 



System Specificatioa for C65 Fred Bowen March 1, 1991 

3.1.4 VaRIflBLES - 

The C64DX uses three types of variables in BASIC; 

floating point X 
integer X% 

string X$ 

Normal NUMERIC VARIABLES, also called floating point variables, can 
have any from up to nine digits of accuracy. When a number 
becomes larger than nine digits can show, as in +10 or -10, the computer 
displays it in scientific notation form^ with the number normalized to 1 
digit and eight decimal places, followed by the letter E and the power 
of ten by which the number is multiplied.- For example, the number 
12345678901 is displayed as 1.23456789E+10. 

INTEGER VARIABLES can be used when the number is a signed whole 
number from +32767 to -32768, Integer data is a number like 5, 10, or 
-100. Integers take up less space than floating point variables, 
particularly when used in an array. 

STRING VARIABLES are those used for character data, which may 
contain numbers, letters, and any other character that the computer 
can make. An example of string data is "Commodore C64DX". 

VARIABLE NAMES may consist of a single letter, a letter followed by 
a number, or two letters. Variable names may be longer than 2 
characters, but only the first two are significant. An integer is 
specified by using the percent (%) sign after the .variable name. String 
variables have a dollar sign ($) after their names. 

EXAMPLES: * 

Numeric Variable Names: A, A5, BZ 

Integer Variable Names: A%, A5%, BZ% 

String Variable Names: A$, A5$, BZ$ 

ARRAYS are lists of variables with the same name, using, an extra 
number (or numbers) to specify an element of the array. Arrays are 
defined using the DIM statement, and may be floating point, integer, or 
string variable arrays. The array variable name is-. followed by a set of 
parentheses (} enclosing the number of the variable in the list, 

EXAMPLE: 
A(7) , BZ%(11), A$(87) 

Arrays can have more than one dimension. A two dimensional array 
may be viewed as having rows and columns, with the first niimber 
identifying the row and the second number identifying the column (as if 
specifying a certain grid on the map) . 

EXAMPLE: 
A(7,2), BZ%(2,3,4), ZS(3,2) 

RESERVED VARIABLE NAMES are names that are reserved for use by the 
computer, and may not be used for another purpose. These are the variables 
DS, DS$, ER, ERRS, EL, ST, TI, and TI$. KEYWORDS such as TO and IF or 
any other names that contain KEYWORDS, such as RUN, NEW, or LOAD cannot 
be used. 

ST is a status variable for input and output (except normal 
screen/keyboard operations) . The value of ST depends on the results of 
the last I/O operation. In general, if the value of ST is then the 
operation was successful. 



TI and TI$ are variables that relate to the real-time clock built 
into the C54DX. The system clock is reset to zero when the system is 
powered up or reset, and can be change^ by the user or a program. 

TI$="hh:inm;sSit" Allows optional colons to delimit parameters and - 

allows input to be abbrieviated (eg., ri$="h:min" or 
even TI$="") , defaulting to "00" for unspecified 
parameters. 24-hour clock (00:00:00.0 to 23:59:59.9) 

TI 24-hour TOD converted into tenths of seconds. 

The value of the clock is lost when the computer is turned off. It 
starts at zero when the computer is turned on, and is reset to zero when 
the value of the clock exceeds 23:59:59.9 , 

The variable DS reads the disk drive conmand channel, and returns 
the current status of the drive. To get this information in words, 
"HINT DS$. These status variables are used after a disk operation, like 
DLOAD or DSAVE, to find out why the error light on the disk drive 
3 blinking, 

ER, EL, and ERR$ are variables used in error trapping routines. 
They are usually only useful within a program. ER returns the last 
error encountered since the program was RUN. EL is the line where the 
error occurred. ERR$ is a function that allows the program to print one 
of the BASIC error messages, PRINT ERR$ (ER) prints out the proper error 
message. 



System Specification for C65 Fred Bowen March 1, 1991 

3.1.5 OPERATORS - 

The BASIC OPERATORS include ARITHMETIC, RELATIONAL, and LOGICAL 
OPERATORS. The ARITHMETIC operators include the following signs: 

+ addition 

subtraction 
* multiplication 
/ division 

raising to a power (exponentiation) 

On a line containing more than one operator, there is a set order 
in which operations always occur. If several operators are used 
together, the computer assigns priorities as follows: First, 
exponentiation, then multiplication and division, and last, addition and 
subtraction. If two operators have the same priority, then calculations 
are performed in order from left to right. If these operations are to 
occur in a different order, BASIC 10.0 allows giving a calculation a 
higher priority by placing parentheses around it. Operations enclosed 
in parentheses will be calculated before any other operation. Make sure 
I that the equations have the same number of left and right parentheses, 
; or a SYNTAX ERROR message is posted when the program is run. 

i There are also operators for equalities and inequalities/ called 

RELATIONAL operators. Arithmetic operators always take priority over 



relational operators. 

= is equal to 

< is less than 

> is greater than 

<= or =< is less than or equal to 

>= or => is greater than or equal to 

<> or >< is not equal to 

Finally, there are three LOGICAL operators, with lower priority 
than both arithmetic and relational operators: 

AND 

OR 

NOT 

These are most often used to join multiple formulas in IF ... THEN 
statements. When they are used with arithmetic operators, they are 
evaluated last (i.e., after + and -) . If the relationship stated in the 
expression is the true the result is assigned an integer of -1 &nd 
if false a of is assigned. There is also an XOR function. 

EXAMPLES : 
> 

IF A=B AND C=D THEN 100 requires both A=^B & C=D to be true 

IF A-B OR C=D THEN 100 allows either A-B or C=D to be true 

A=5:B=4:PRINT A=B displays 

A=5:B=4:PRINT A>3 displays -1 

PRINT 123 AND 15:PRINT 5 OR 7 displays 11 and 7 



System Specification for C65 



Fred Bowen 



March 1, 1991 



3.1.6 ERROR MESSAGES - 
3.1.6.1 BASIC ERROR MESSAGES - 

The following error messages are displayed by BASIC. Error 
messages can also be displayed with the use of the ERR5() function The 
error number refers only to the number assigned to the error for use 
With this function. In direct mode, DOS error messages (DS$) are 
automatically displayed. They are described in the section after this one 



ERROR # ERROR NAME 

1 TOO MANY FILES 



DESCRIPTION 



2 FILE OPEN 

3 FILE NOT OPEN 

4 FILE NOT FOUND 

5 DEVICE NOT PRESENT 

6 NOT INPUT FILE 

7 NOT OUTPUT FILE 

8 > MISSING FILE NAME 

9 ILLEGAL DEVICE NUMBER 

10 NEXT WITHOUT FOR 

11 SYNTAX ERROR 

12 RETURN WITHOUT GOSUB 

13 OUT OF DATA 

14 ILLEGAL QUANTITY 

15 OVERFLOW 

16 OUT OF MEMORY 



There is a limit of 10 files OPEN 
at one time. 

An attempt was made to open a file using 
the niimber of an already open file. 

The file number specified in an I/O 
statement must be opened before use. 

No file with that name exists on the 
specified drive. 

The required I/O device not available. 

An attempt made to read data from a 
file that was opened for writing. 

An attempt was made to write data to a 
file that was opened for reading. 

Filename was missing in command. 

An attempt was made to use a device 

improperly (SAVE to the screen, etc) 

or an illegal device number was specified: 

Either loops are- nested incorrectly, or 
there is a variable name in a NEXT statement 
that doesn't correspond with one in FOR. 

A statement is unrecognizable by BASIC. 
This could be because of missing or extra 
parenthesis, parameters, delimiters, or a 
mispelled keyword. 

A RETURN statement was encountered when 
no GOSUB statement was active. 

A READ statement was encountered with no 
DATA left unREAD. 

A number used as an argument is outside 
the allowable range (too big or too small) . 

The result of a computation is larger than 
the largest number allowed (1.701411834E+38) 

There is not enough memory for the program, 
or variables, or there are too many DO, FOR 
or GOSUB statements in effect. 



17 
18 

19 
20 
21 

22 

23 

24 
25 

26 

27 

28 

29 
30 

31 

32 
33 

34 

35 

36 

37 
38 



XJNDEF'D STATEMENT 
BAD SUBSCRIPT 

REDIM'D ARRAY 
DIVISION BY ZERO 
ILLEGAL DIRECT 

TYPE MISMATCH 

STRING TOO LONG 

FILE DATA 

FORMDLA TOO COMPLEX 

CAN'T CONTINUE 

UNDEFINED FUNCTION 
VERIFY 

LOAD 

BREAK 

CAN'T RESUME 

LOOP NOT FOUND 

LOOP WITHOUT DO 

DIRECT MODE ONLY 

NO GRAPHICS AREA 

BAD DISK 

BEND NOT FOUND 

LINE NUMBER TOO LARGE 



A line number referenced doesn't exist. 

The program tried to reference an element 
of an array out of the range specified by 
a DIM statement, a missing DIM statement, 
or a mistyped function name. 

An array can only be DIMensioned once. 

Division by zero is illegal. 

Command is only allowed to be used in a 
program, 

A numeric variable was used in place of a 
string variable or vice versa. 

An attempt was made to assign more than 255 
characters to a string, or enter more than 
160 characters from the keyboard, or to 
input. more than 255 characters from a file. 

The wrong type of data was read from a file 

An expression is too complicated for BASIC 
to process all at one time. Break it into 
smaller pieces or use fewer parentheses. 

The CONT command does not work if the 
program was not RUN, there was an error, 
or a line has-been edited. 

An^attempt was made to use a user defined 
function that was never defined. 

The program on disk does not match the 
program in memory. 

There was a problem loading. 

The program was halted by the STOP key or 
a STOP statement: 

A RESUME statement was encountered without 
a TRAP in effect, or an error occurred in 
the trap handler itself. 

t 

The program encountered a DO statement and 
cannot find the corresponding LOOP. 

A LOOP was encountered without a DO 
statement active. 

A command was used in a program that can 
only be used in direct mode. 

A graphics command was used before a 
graphics screen was defined and opened. 

A BOOT SYS command failed because the 
disk could not be read. 

A BEND statement not found for BEGIN. 

A line number cannot exceed 64000. 



39 UNRESOLVED REFERENCE Rentimber failed because a referenced 

line number does not exist . 

40 UNIMPLEMENTED COMMAND The given command is not currently- 

implemented in this computer. 

41 FILE READ There was a problem reading data from 

a disk file. Similar to LOAD ERROR* 



System Specification for C65 Fred Bowen March 1, 1991 

3-1.6.2 DOS ERROR MESSAGES - 

.r^^A.Z^^ following error messages are returned through the DS and DS$ 
kJ i- 1 ^ ^^ ^ ^^^ command is type in direct mode, these messages will 
be dxspiayed automatically. NOTE: DOS message numbers less than 20 are 
H^^^^S^ ^""^ ^'^?u"°^ necessarily errors. DOS messages may vary slightly 
depending upon the drive model. Refer to your DOS manual for details! 



ERROR # DESCRIPTION 
00: OK {no error) 



01: FILES SCRATCHED (not an error) 

The following number (track) tells how many files were 
deleted by the scratch command. 

02: PARTITION SELECTED (not an error) 

The requested dislc partition (subdirectory) has been selected, 

03: FILES LOCKED 

The requested file(s) have been locked. 

04: FILES UNLOCKED 

The requested file(s.) have been unlocked. 

05: FILES RESTORED 

The requested file(s) have been recovered (undeleted). 

20: READ ERROR (block header not found) 

The disk controller is unable to locate the header of the 
requested data block . paused by an illegal sector number, 
or the header has been'destroyed. 

21: READ ERROR (no sync character) 

The disk controller in unable to detect a sync mark on the 
desired track. Caused by misalignment of the read/write 
=!f?'^"2- i^^®^^^^^^ present, or unformatted or improperly 
seated diskette. Can also indicate a hardware failure 

22: READ ERROR (data block not present) ■ 

The disk controller has been requested to read or verify a 
data block that was not properly written. This error occurs 
in connunction with the BLOCK commands and indicates an il- 
legal track and/or sector request. 

23: READ ERROR (checksum error in data block) 

This error message indicates that there is an error in one 
or more of the data bytes. The data has been read into the 
DOS memory, but the checksum over the data is in error 
This message may also indicate grounding problems. 

24: READ ERROR (byte decoding error) 

The data or header has been read into the DOS memory, but a 
hardware error has been created due to an invalid bit pat- 
tern m the data byte. This message may also indicate ground- 
ing problems . 

25: WRITE ERROR (write-verify error) 

This message is generated if the controller detects a mis- 
match between the written data and the data in the DOS mem- 
ory. 

26.: WRITE PROTECT ON 



This message is generated when the controller has been re- 
quested to write a data block while the write protect switch 
is depressed. 

27: -READ ERROR 

This message is generated when a checksum error is in the 
header. 

28: WRITE ERROR 

This error message is generated when a data block is too long. 

29: DISK ID MISMATCH 

This message is generated when the controller has been re- 
quested to access a diskette which has not been initialized. 
The message can also occur if a diskette has a bad header. 

30: SYNTAX ERROR (general syntax) 

The DOS cannot interpret the command sent to the command 
channel. Typically, this is caused by an illegal number of 
file names, or patterns are illegally used. For example, 
two file names appear on the left side of the COPY command. 

31: SYNTAX ERROR (invalid command) 

The DOS does not recognize the command. The command must 
start in the first position. 

32: SYNTAX ERROR (invalid command) 

The command sent is longer than 58 characters. 

33: SYNTAX ERROR (invalid file name) 

Pattern matching is invalidly used in the OPEN or SAVE 
command . 

34: SYNTAX ERROR (no file given) 

The file name was left out of the command or the DOS does 
not recognize it as such. 

39: SYNTAX ERROR (invalid command) 

This error may result if the command sent to the command 
channel (secondary address 15) is unrecognized by the DOS. 

40: UNIMPLEMENTED COMMAND 

Command is not implemented at this time. 

41: FILE READ 

The file cannot be read 

50: RECORD NOT PRESENT , 

Result of disk reading past the last record through INPUT* 
or GET# commands. This message will also occur after posi- 
tioning to a record beyond end_of file in a relative file. 
If the intent is to expand the fiXe by adding the new record 
(with a PRINT* command), the error message may be ignored. 
INPUT and GET should not be attempted after this error is 
detected without first repositioning. 

51: OVERFLOW IN RECORD 

PRINT! statement exceeds record boundary. Information is 
truncated. Since the carriage return which is sent as a 
record terminator is counted in the record size, this mes- 
sage will occur if the total characters in the record 
(including the final carriage return) exceeds the defined. size 

52: FILE TOO LARGE 

Record position within a relative file indicates that disk 
overflow will result. 



53: BIG RELATIVE FILES DISABLED 

60: WRITE FILE OPEN 

This message is generated when a write file that has not 
been closed is being opened for reading. 

61: FILE NOT OPEN 

This message is generated when a file is being accessed that - 
has not been opened in the DOS. Sometimes, in this case, a 
message is not generated; the request is simply ignored. 

62: FILE NOT FOUND 

The requested file does not exist on the indicated "drive. 
63: FILE EXISTS 

5u® 5^^? "^® °^ ^^® ^^^® being created already exists on 
the axskette . 

Q^i FILE TYPE MISMATCH 

The requested access mode is not possible using the filetype 

65: NO BLOCK 

I?L!h''^°Ti^°^^5^®'^ 5° allocate with the B-A command was 
h^^^tt^ ^ ^^f^^?'^-. ^^f '^''5^*' ^"^ sector numbers hold the next 
hxgher, available track and sector. If the track number is 
zero, no higher sectors are free (try a lower track s sector) . 

66: ILLEGAL TRACK AND SECTOR 

The DOS has attempted to access a track or block which does 
^Zl A^ "-".w^ format being used. This may indicate a prob- 

lem reading the pointer of the next block. 

67: ILLEGAL SYSTEM T OR S ^ 

This special error message indicates an illegal system 
track or sector, ^ 

70: NO CHANNEL 

?^^.«!'^f^^®'^-'=^^'^'^2^.^^ "^"^ available, or all channels are 
in use. A maximum of five sequential files may be opened at 
one time to the DOS. Direct access channels miy havl six 
opened files. .-. 

71: . DIRECTORY ERROR 

The BAM is corrupted. Try initializing the disk. 

72: DISK FULL 

Either the blocks on the diskette are used or the directory 
IS at Its entry limit. DISK FULL is sent when two blocks are 
available to allow the current file to be closed before its 
data is lost. 

73: DOS MISMATCH (also the powerup message) 

Initially given at powerup to identify the drive. On some 
drives this message is given as an error to indicate the 
media was formatted by an incompatible DOS. 

74: DRIVE NOT READY 

An attempt has been made to access the Floppy Disk Drive 
without any diskette present. 

75: FORMAT ERROR 

76: CONTROLLER ERROR 

The DOS has determined that the hardware is malfunctioning. 



77: 



78: 



79: 



SELECTED PARTITION ILLEGAL 

An attempt was made to access a partition as a subdirectory, 
but it has no directory track or does not meet the criteria 
of a directory partition. 

DIRECTORY FULL 

There is no more room in the directory sector for another 

file entry. Delete a file to make room, or change disks. 

FILE CORRUPTED 

The DOS has determined that a file is bad, probably having 
bad links. Prepare a new disk and copy the good files to it 
Could be the result of an. unsuccessful file recovery. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



^'2 MRCaiNE lANGDRGE MONITOR 
3.2.1 INTRODUCTION 

the user easUy\ritl maohL^", '""=*''"" '""^^'^ ^"^^^ ^^-^- ^^ts 

a machine lan^^a^e^^^^nTt%=^ran\^^S^'!er£n-=^^^l3^?L"°^^^°^ ^-^"^- 

themsSves?^ lT'^t^\HT^\:rt^Tr''f^''f, the. MONITOR can run by 



3.2.2 MONITORCOMMANDS 



A 


ASSEMBLE 


C 


COMPARE 


D 


DISASSEMBLE 


F 


FILL 


G 


GO 


H 


HUNT 


L 


LOAD 


M 


MEMORY 


R 


REGISTERS 


S 


SAVE 


T 


TRANSFER 


V 


VERIFY 


X 


EXIT 


. 


<period> 


> 


<greater-than> 


# 


<semicolon> 


e 


<at sign> 


$ 


<hex) 


+ 


<decimal> 


& 


<octal> 


% 


<binary> 



Assemble a line of 4502 code 
Compare two sections of memory 
Disassemble a line of 4502 code 
Fill a section of memory with a value 
Start execution at specified address 

fi^H f^l^^^!"^ "^^^^ ^" ^ section of memory 
Load a file from disk 

Dump a section of memory 

Display the contents of the 4502 registers 

bave a section of memory to a disk file 

Transfer memory to another location 

E^T^M^.^^^''^^^'' °^ memory with a disk file 
AXit Monitor mode 

Assembles a line of 6502 code 
Modifies memory 
Modifies register contents 
Display disk status 

Display hex, decimal, octal, and binary value 



System Specification for C6S 



Fred Bowen 



March 1, 1991 



The MONITOR accepts binary, octal, decimal and hexadecimal 
values for any numeric field. Numbers prefixed by one of the 
characters $ + s % are interpreted as base 16, 10, 8, or 2 values 
respectively. In the absence of a prefix, the base defaults to 
hexadecimal always. 

The assembler will use the base page form of an instruction wherever- 
possible unless the address field is proceeded by extra zeros to force 
the absolute form (except binary notation) . 

The most significant byte of a 24-bit (3-byte) address field 
specifies the memory BANK to implement at the time the given 
command is executed. BANK bytes with the MSB set (i.e., banks 
greater than $7F) mean "use the current system configuration", 
which always includes -the I/O area. If a BANK is not specified, 
BANK is assumed. 



BANK 00 
BANK 01 
BANK 02 
BANK 03 

BANK 04-07 

BANK 08-7F 

BANK 80-FF 



internal RAM bank (System, BASIC program) 

internal RAM bank 1 (DOS, BASIC vars, color bytes 

internal ROM bank (DOS, C64 mode, CHRSETS) 

internal ROM bank 1 (Monitor, C65 mode) 

reserved for future expansion 

expansion RAM (graphic screens, RAM disk, etc.) 

MSB set means current config & I/O 



The monitor supports the editor autoscrol.l feature for memory dumps 
(forwards and backwards) and disassemblies (forward disassembly only) . 

To send dump output to a printer, from BASIC open a CMD channel to the 
printer and enter the monitor (OPEN 4,4: CMD4: MONITOR). Give the 
d; ^p command desired; output will be to the printer. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



3.2.3 MONITOR COMMftKP DESCRIPTIONS 



C0^3MAND: 
PURPOSE : 
SYNTAX: 

<address> 



<innemonic> 
<operand> 



Enter a line of assembly code. 
A <address> <mnemonic> <operand> 

A number indicating the location in memory to 
place the assembled binary code. 

A 4502 assembly language mnemonic, eg., LDA 

The operand, when required, can be of any 
of the legal addressing modes. 



A RETURN is used to indicate the end of the assembly line. If 
are any errors on the line, a question mark is displayed to 
an error, and the cursor moves to the next line. The screen 
can be used to correct the error (s) on that line. 

As each line is entered, the machine code is written to the specified 
address and the line is automatically disassembled. 

Base page and relative addresses are calculated for you, and the 
appropriate word or byte relative mode selected automatically. To 
force an absolute addressing mode, supply leading zeros if necessary. 

.A 1800 LDX #$00 
.A 1802 

NOTE: A period {.) is equal t^ the ASSEMBLE command. 

. 1900 LDA #523 



COMMAND: 
PURPOSE: 
SYNTAX : 

<address 1> 
<address 2> 
<address 3> 



Compare two areas of memory 

C <address 1> <address 2> <address 3> 

A number indicating the start 

of the area of memory to compare against. 

A ntimber indicating the end 

of the area of memory to compare against. 

A number indicating the start 

of the other area of memory to compare with. 



The following example compares $8000-$9FFF in bank with $8000-$9FFF 
in bank 1. Addresses of data that does not match are printed on the 
screen. 

C 8000 9FFF 18000 



COMMAND: 
PURPOSE: 
SYNTAX : 

<address> 

<address 2> 



D 



Disassemble machine code 
D [address_l [address_23 ] 

A number setting the address to start the disassembly, 

An optional ending address of code to be disassembled. 



The output of the disassembly is the same as-that of an assembly, 
only preceded by a comma instead of an A or period. The object 
code is also displayed. Relative addresses in the disassembly are 
displayed as the 16-bit destination, 

A disassembly listing can be modified using the screen editor, 
any changes to the mnemonic or operand on the screen, then hit the 
return. -This enters the line and calls the assembler for 
instructions. The object code cannot be modified this way. 

A disassembly can be paged. Typing a D <retum> causes the next 
of disassembly to be displayed. The autoscroll feature works in 
forward mode only, because backwards disassembly is not possible 
since all 256 opcodes are defined in the 4502 processor. 

The following example disassembles from ROM bank 3 : 



D 3F0OO 3F005 
. 03F000 AS 09 
. 03F002 AC FF 
. 03F004 18 
. 03F005 86 C2 



LDA #$09 
LDY #$FF 
CLC 
STX $C2 



Note that banks wrap to the next higher bank number. 



COMMAND: 
PURPOSE: 
SYNTAX : 

<address 1> 

<address 2> 

<byte> 



Fill a range of locations with a specified byte. 
F <address 1> <address 2> <byte> 

The first location to fill with the <byte>. 

The last location to fill' with the <byte>. 

The byte to fill with 



T'?is command is useful for initializing data structures or any 
other RAM area. 

F 00600 007FF 00 

Fills memory locations from $0600 to $07FF (RAM-O) with $00. 
Note that banks wrap to the next higher bank number. The maximum 
area that can be filled at one time is 64K, limited by the DMA 
device , 

COMMAND: G , 

PURPOSE: Perform a JMP to a specified address 
SYNTAX: G <address> 

<address> The address where execution is to start. When the 
address is not specified, execution begins at the 
current PC. (The current PC can be viewed or changed 
with the R command.) 

The GO command loads the processor's registers (displayable by the R 
command) and performs a JMP to the specified starting address. 
Caution is recommended in using the GO command. To return to MONITOR 
mode after performing a GO command, a BRK instruction must end the 
called routine. Also, the BANK specified must be able to handle 
interrupts (note that BANK bytes less than $80 do NOT include the 
operating system or I/O space) . 



G FFCSOO 



JuMPs to address $C800 in bank SfF (system configuration) . 



COMMAND: 
PURPOSE: 

SYNTAX : 

<address 1> 

<address 2> 

<data> 



H 

Hunt through laemory within a specified range for all 
occurences of a set of bytes. 
H <address 1> <address 2> <data> 

Address to start at 

Last address 

Data to search for. May be a number, sequence of 
numbers, or a PETSCII string. 

H 02O00 OFFFF 46 52 45 44 

Hunts for the series of bytes $46, $52, $45, $44 in memory bank 
beginning at address $2000 and ending at $FFFF. The addresses of 
matches is displayed. 

H 0200 OFFFF 'FRED 

Hunts for the PETSCII string following an apostrophe. 
Note that banks wrap to the next higher bank number. 



COMMAND: 
PURPOSE: 
SYNTAX : 

<"filename"> 

[device] 

[load address] 



Load a file from disk. 

L <"fiiename"> [, device [, load__address] ] 

Is a filename in quotes.. 

Is a number indicating the device to load from. 

Optional load address. If not given, the file is 
loaded into memory at the 16-bit address stored on 
disk (always RAM bank 0) . 

The LOAD command causes a file to be loaded into memory. If the load 
address (including BANK) is given, the data is placed there. Otherwise 
the file is loaded into RAM bank at the 16-bit load address specified 
by the first two bytes read from the PRG (program) type file. An error 
occurs xf a load overflow the specified bank. 

L "filename" 

Loads "filename" from default system drive into RAM bank at the 
address read from the file. 

L "filename", +10, 80000 

Loads "filename" from drive 10 {notice you must specify decimal for 
the drive number, or use hex equivalent) into expansion memory bank 
8 at address $0000. Note that spaces between parameters after the 
filename are not permitted. 



COMMAND : 
PURPOSE: 
SYNTAX: 

[address_l] 
(address 2] 



M 

Dump a section of memory in hex and PETSCII. 

M [address_l [address__2} ] 

Starting address of memory dump. If omitted, one page 
is displayed starting from the last address used. 

Ending address of memory dximp. If omitted, one page 



is displayed starting at address_l. 

Memory dump width is sized to 40 or 80 columns, depending upon the 
text screen width. All data is displayed in hexadecimal and followed 
by a PETSCII interpretation of the data in reverse field (non-printing 
characters appear as periods) . 

The autoscroll keys will scroll the dump forwards or backwards. Paging 
is also possible by typing M<return>. 

The hex field of dump can be edited, and memory will be updated after 
a <return> is typed on the edited line. 

M 29000 2900C 

>029000 3C 66 6E 6E 60 62 3C 00 :<FNN-B<. 
>029008 46 41 49 54 20 4C 55 58 :FAIT LUX 

COMMAND : R 

PURPOSE: Display "shadow" 4502 registers. The PC (address), 

SR (status), A,X,Y,2 registers, and SP (stack pointer) 

are displayed. 
SYNTAX: R 

R 

PC SR AC XR YR SP 

; BA1234 00 00 00 00 FB 

The address field contains the 8-bit bank plus the 16-bit segment 
address. The register dump can be edited by changing any field and 
pressing return. The data is used by the .G (JMP) and J (JSR) commands. 

COMMAND: S 

PURPOSE: Save a section of memory in a disk file. 

S^^TAX: S <"filename">,<device>,<address l>,<address 2> 

<"filename''> Is a filename in quotes. 

<address 1> Starting address of memory to be saved. 

<address 2> Ending address PLUS ONE of memory to be saved. 

The SAVE command creates a PRG (program) type file and copies data 
into it from the specified memory area. All parameters are required. 

S "filename", 8, AOOO.0,AFFFF » 

Saves expansion bank A in "filename" on drive 8 (you must specify 
decimal for the drive number, or use hex equivalent). The last byte 
at SFFFF will not be saved. Note that spaces between parameters after 
the filename are not permitted. The 16-bit segment address is saved 
as the first two bytes of the file, but the BANK, address is not saved. 

The BANK wraps automatically to the next higher bank number, but note 
that LOAD is restricted to one bank, 64K bytes maximum. 

COMMAND: T 

PURPOSE: ■ Transfer (copy) memory from one memory area to another. 

SYNTAX: T <address 1> <address 2> <address 3> 

<address 1> Starting address of data to be copied. 

<address 2> Ending address of data to be copied. 



<address 3> 



Starting address of new location to copy data to. 



Data can be copied forwards or backwards to any location, even 
Within the source range (eg., shift data up or down one byte) without 
any problem. _ An automatic compare is performed for each byte, and 
mismatches displayed on the screen. 

Because of the compare feature, it's not recommended you use the T " 
command to copy data into write-only registers (the palette, for 
example). It works, but all the compares will fail. 

T 32000 3BFFF 82000 
Copies BASIC ROM area to expansion RAM. 



COMMAND : 
PURPOSE: 
SYNTAX : 



V 

X^5i!^i (compare) a disk file with the memory contents. 
V < filename"> [, device [,load_address] ] 

<"filename"> Is a filename in quotes. 

[device] is a number indicating the device the file is on. 

[load_address] Optional load address. If not given, the file is 
compared to memory at the 16-bit address stored on 
disk (always RAM bank 0) . 

?f%hrtSH''^;^^"'^ ""^""^^^ ;.^^^^ ^° ^® ^^^^ ^^^ compared to memory. 
If the load address (including BANK) is given, the data r^Ad i «5 

banrrft"?heit bi^?; /^^^"'^^ ^^^ dIta"?4ad'^!s^compIrtd to RAM 
n? ^>,I S«r^ 16-bxt load address specified by the first two bytes 

?wRilY?5r pS^oIf^* w^P^^^^i• ^^ ^^^^^ i= ^ mismatch, the message 
hT?^?! iS ^P°^ ^^ displayeS. If the data matches, nothing is 

^if^ ?^^*K ^ ^''''°'' "'"'''^''^ ^^ ^^® compare address overflows the 
speciried bank, 

V "filename" 

V "filename", +10, 80000 

tSr£?5."n»iS2r^" ^''°"' i^^^^ ^9 <"^^^^® y<=>^ ™^st specify decimal for 
8 ai-^HH^.^^^nnnn S ? ^?? equivalent) to expansion memory bank 
8 at address $0000. Note that spaces between parameters* after the 
filename are not permitted. a-i-i-cx une 



COMMAND: 
PURPOSE: 
Slf NTAX : 



Exit to BASIC 
X 



COMMAND : 
PURPOSE: 
SYNTAX : 

<address> 

[byte] 



> , (greater than) 

Pokes data (1 to 16 bytes) into memory 

> <address> [byte]... 

Address to start "poking" or displaying 

Data to be "poked". If not given, nothing is 
cnanged and the memory at that location is "peeked". 
Successive bytes are poked into successive locations 



COMMAND: @ (at sign) 

PURPOSE: Disk operation: send command, display directory, status 

SYNTAX: @ [device] [, command] 

[device] Disk device nvimber 

[command] Optional command (see DOS manual for specific commands) 

This command can be used to read a drive's status message/ send 
a drive a DOS command, or display a dislt directory* 

@ displays status of default system drive 

@9 displays status of drive 9 

@+10 or @A displays status of drive 10 

@/$ displays directory of default drive 

@9,S displays status of drive 9 

e,$0:*=SEQ displays all SEQ type files 

@, SO: FILE sends command to delete file "FILE" 



System Specification for C65 Fred Bowen March 1, 1991 

3,3 EDITOR 

3.3.1 EDITOR ESCAPE SEQUENCES 

This section contains a definition of the escape sequences that are present in 
.the C64DX and a brief description of what each does. 

f^'^SS?.™®*^^'?^®® ^^® given by hitting the <ESCAPE> key and then another key. 
rStjc^o?? ?'^f^"^^i escape sequences are given by printing the escape character 
Q-HR9(Z7) followed by another character. In either case, the "other" character 
IS defined as one of the following: 

KEY FUNCTION 



@ Clear from cursor to end of screen 

A Enable auto-insert mode 

B Set bottom of screen window at cursor position 

G Disable auto-insert mode (set overwrite mode) 

D Delete current line 

E Set cursor to non-flashing mode 

F Set cursor to flashing mode 

G Enable bell (control-G) 

H Disable bell 

I Insert line 

J Move to start of current line 

K Move to end of current line 

L Enable scrolling 

M Disable scrolling 

N Normal screen fields [-not implemented on C64DX] 

Cancel insert, quote, reverse, underline 4 flash modes 
P Erase from cursor to start of current line 

Q Erase from cursot'to end of current line 

R Set screen to reverse video [not implemented on C64DX] 

S Set bold attribute (VIC-III colors 16-31) 

T Set top of screen window at cursor postion 

U Unset bold attibute 

V Scroll up 

W Scroll down 

X Swap 40/80 column display output device 

Y Set default tab stops (8 spaces) 
Z Clear all tab stops 

[ Set monochrome display (disable attributes) 

\ Cancel insert, quote, rvs, ul & flash modes 

1 Set color display (enable attributes) 



System Specification for C65 



Fred Bowen 



March 1, 1991 



3.3.2 EDITOR CONTROL COPES 

This section contains a definition of the control codes that are present in 
the C64DX and a brief description of what each does. 

Control codes are given by pressing the <CTRL>]cey at the same' time as another 
key. In PRINT strings, control codes are given by printing the control 
character with the CHR${} function. Control codes appear within quoted strings 
as reverse field characters. In any case, the control characters are: 



CHRS 


KEYBOARD 


VALUE 


CONTROL 


2 


B 


7 


G 


9 


I 


10 


J 


11 


K 


12 


L 


14 


N 


15 





17 


Q 


18 


R 


19 


S 


20 


T 


21 


U 


23 


W 


24 


X 


26 


z 


27 


[ 


29 


] 



FUNCTION 



Underline on 

Bell tone 

Forward TAB 

Line feed 

Disable case change <shift>C= key (was code 9) 

Enable case change <shift>C= key (was code 8) 

Set display upper/lower case mode 

Flash on 

Cursor down 

Reverse on 

Home cursor 

Delete previous, character 

Backup word 

Advance word 

Tab set/clear 

Backup TAB 

Escape character 

Cursor right 



System Specification for C65 
Shifted codes 



Fred Bowen 



March 1, 1991 



130 
142 
143 

145 
146 
147 
148 
157 

Color codes 



5 

28 

30 

31 

129 

144 

14 9 

150 

151 

152 

153 

154 

155 

156 

158 

159 

Function keys 



3 

16 

21 

22 

23 

25 

26 

131 

132 

133 

134 

135 

136 

137 

138 

139 

140 



Underline off 

Set uppercase/graphic mode 

Flash off 

Cursor up 

Reverse mode off 

Clear screen 

Insert one character 

Cursor left 



white 
red 
green 
blue 
orange 
black 
brown 
light red 
light gray 
medium gray 
light green 
light blue 
dark gray 
purple 
yellow 
cyan 



Stop * 

F9 

FIO 

Fll 

F12 

F13 

F14 

Run 

Help 

Fl 

F3 

F5 

F7 

F2 

F4 

F6 

F8 



System Specification for C65 



Fred Bowen 



March 1, 1991 



3.4 KERNEL 

3.4.1 C64DX KERNEL ENTRY POINTS 



[*** THE FOLLOWING VECTORS AND JUMP TABLES AKE NOT FINAL ***] 
Where the default indirect vectors point to: 



FF09 


nirq 


; IRQ handler 


FFOB 


monitor_brk. 


;BRK handler (Monitor) 


FFOD 


nnjQi 


;NMI handler 


FFOF 


nopen 


;open 


FFll 


nclose 


; close 


FF13 


nchkin 


; chkin 


fb-lS 


nek out 


; ckout 


FF17 


nclrch 


; clrch 


FF19 


nbasin 


; basin 


FFIB 


nbsout 


■;bsout 


FFID 


nstop 


;stop key scan 


FFIF 


ngetin 


; get in 


FF21 


nclall 


;clail 


FF23 


monitor_parser 


; monitor command parser 


FF25 


nload 


; load 


FF27 


nsave 


; save 


FF29 


talk 


;Low level serial bus r 


FF2B 


listen 




FF2D 


talksa 




FF2F 


second 




FF31 


acptr 




FF33 


ciout 




FF35 


untalk 




^JZl 


uniisten 





FF39 
FF3B 
FF3D 
FF3F 
FF41 
FF43 
FF45 
FF47 

FF49 

FF4B 

FF4D 
FF50 
FF53 
FF56 
FF59 
FF5C 
FF5F 
FF62 
FF65 
FF68 
FF6B 
FF6E 
FF71 
FF74 
FF77 
FF7A 



DOS 
DOS' 
DOS" 
DOS' 
DOS' 
DOS" 
DOS" 
DOS' 



talk 

glisten 

"talksa 

^[second 

[acptr 

"ciout 

"untalk 

"uniisten 



;newDOS routines 



Get_DOS 
Leave_DOS 

jmp spin_spout 
jmp close all 
jmp c64moHe 
jmp monitor_call 
jmp bootsys 
jmp phoenix 
jmp Ikupla 
jmp Ikupsa 
jmp swapper 
jmp pfkey 
jmp setbnk 
jmp jsr_far 
jmp jmp_far 
jmp lda_far 
jmp sta_£ar 
jmp cmp_^far 



setup fast serial port for input or output 

close ail logical files for a given device 
■reconfigure system as a c/64 (no return!) 

map in Monitor & call it 

boot alternate system from disk 
■call cold start routines, disk boot loader 
: search tables for given la 
^search tables for given sa 
:swap to alternate display device 
: program function key 
rset bank for load/save/verify/open 
rJSR to any bank, RTS to calling bank 
r JMP to any bank 
rLDA (X),Y from bank 2 
jSTA (X),Y to bank Z 
rCMP (X),Y to bank Z 



FF7D 

FF80 

FF81 

FF84 

FF87 

FF8A 

FF8D 

FF90 

FF93 

FF96 

FF99 

FF9C 

FF9F 

FFA2 

FFA5 

FFA3 

FFAB 

FFAE 

FFBl 

FFB4 

FFB7 

FFBA 

FFBD 

FFCO 

FFC3 

FFC6 

FFC9 

FFCC 

FFCF 

FFD2 

FFD5 

FFD8 

FFDB 

FFDE 

FFEl 

FFE4 

FFE7 

FFEA 

FEED 

FFFO 

FFF3 

FFF6 
FFF8 

FFFA 
FFFC 

FFFE 



3inp priirau 

<FF> 

jmp cint 
jmp ioinit 
jitip ramtas 
jmp res tor 
jmp vector 
jmp setmsg 
jmp (isecond) 
jmp (italksa) 
jmp memtop 
jmp membct 
jmp key 
jmp settmo 
jmp (iacptr) 
jmp (iciout) 
jmp (iuntalk) 
jmp (iunlisten) 
jmp (ilisten) 
jmp (itaik) 
jmp readss 
jmp set If s 
jmp set nam 
jmp (iopen) 
jmp (iclose) 
jmp (ichkin) 
jmp (ickout) 
jmp (iclrch) 
jmp (ibasin) 
jmp (ibsout) 
jmp load 
jmp save 
jmp Set Time 
jmp ReaH^Tinie 
jmp (istop) 
jmp (igetin) 
jmp (iclall) 
jmp ScanStopKey 
jmp scrorg 
jmp plot 
jmp iobase 



c65mode 
c64mode 

nmi 
reset 

irq^kernel 



; print immediate (always JSR to this routine!) 

;release number of C65 Kernel ($FF=not released) 

;init screen editor £ display chips 

;init I/O devices (ports, timers, etc.) 

/initialize RAM for system 

/restore vectors to initial system 

/change vectors for user 

/control o.s. messages 

/send sa after listen 

/send sa after talk 

/set/read top of memory 

/set/read bottom of memory 

/scan keyboard 

/old IEEE set timeout value 

/read a byte from active serial bus talker 

/send a byte to active serial bus listener 

/command serial bus device to stop talking 

/command serial bus device to stop listening 

/command serial bus device to listen 

/command serial bus device to talk 

/return I/O status byte 

/set la, fa, sa 

/set length and fn adr 

/open logical file 

/close logical file 

; open channel in 

/ open channel out 

/close I/O channel 

; input from channel 

/output to channel 

/load from file 

/save to file 

; set Internal clock 

.-read internal clock 

; scan stop key 

/ get char from queue 

/clear all logical files (see close all) 

/ (was increment clock) & scan- stop Icey 

; return current screen window size 

/read/set x, y coord 

/return I/O base 

;C64/C65 interface 



/processor hardware vectors 



System Specification for C65 



Fred Bowen 



March 1, 1991 



3.4.2 C€4DX EDITOR JDMP TftBLE 

[*** THE FOLLOWING VECTORS AND JUMP TABLES ARE NOT FINAL ***] 

/initialize editor & screen 

; display character in .a, color in .x 

;get a key from IRQ buffer into .a 

;get a chr from screen line into .a 

; print character in .a 

;get size of window (rows^cols) in .x, .y 

;scan keyboard subroutine 

/repeat key logic & CKIT2 to store decoded key 

/read or set (.c) cursor position in .x, .y 

/install/remove mouse driver 

/execute escape function using chr in .a 

/ redefine a programmable function key 

/ IRQ entry 

/ initialize VIC palette 

/ 40/80 mode change 

;set top left or bottom right (.c) of window 

/turn on or off (.c) soft cursor 



EOOO 


cint 


E003 


disply 


E006 


lp2 


E009 


loop5 


EOOC 


print 


EOOF 


scrorg 


E012 


keyboard scan 


E015 


■ repeat 


E018 


plot 


EOIB 


mouse_cmd 


EOIE 


es cape 


E021 


keyset 


E024 


editor_irq 


E027 


palette_init 


E02A 


swap 


E02D 


window 


E030 


cursor 



System Specification for C65 



Fred Bowen 



March 1, 1991 



3.4.3 C64DX BASIC JPMP TABI.E 

[*** THE FOLLOWING VECTORS AND JUMP TABLES ARE NOT FINAL ***] 
Format Conversions 



7F00 
7F03 
7F06 
7F09 
7F0C 
7F0F 



ayint 

givayf 

fout 

val_l 

getadr 

float c 



Math Functions 



7F12 

7F15 

7F18 

7F1B 

7F1E 

7F21 

7F24 

7F27 

7F2A 

7F2D 

7F30 

7F33 

7F3 6 

7F39 

7F3C 

7F3F 

7F42 

7F45 

7F48 

7F4B 

7F4E 

7F51 

7F54 

7F57 



fsub 

f subt 

fadd 

faddt 

fmult 

fmuitt 

fdiv 

fdivt 

log 

int 

sqr 

negop 

fpwr 

fpwrt 

exp 

cos 

sin 

tan 

atn 

round 

abs 

sign 

f comp 

rnd 



Movement 



7F5A 

7F5D 

7F60 

7F63 

7F66 

7F69 

7F6C 

7F6F 

7F72 

7F75 

7F78 

7F7B 

7F7E 

7F81 

7F84 

7F87 

7F8A 

7F8D 

7F90 

7F93 

7F96 



conupk 

romupk 

movfrm 

movfm 

movmf 

movfa 

movaf 

run 

rune 

clear 

new 

linlc_prograin 

crunch 

FindLine 

newstt 

eval 

frmevl 

run_a_p r o gr am 

setexc 

linget 

garb a 2 



; convert 
; convert 
; convert 
; convert 
; convert 
; convert 



floating point to integer 
integer to floating point . 
floating point to ASCII string 
ASCII string to floating-point 
floating point to an address 
address to floating point 



;MEM 
;ARG 
;MEM 
;ARG 
;MEM 
;ARG 



FACC 

FACC 

FACC 

FACC 

FACC ' 

FACC 
;MEM / FACC 
;ARG / FACC 

/compute natural log of FACC 
/perform BASIC INT () on FACC 
/compute square root of FACC 
/negate FACC 

/raise ARG to the MEM power 
/raise ARG to the FACC power 
/compute EXP of FACC 
/ compute COS of FACC . 
/compete SIN of FACC 
/compute TAN of FACC 
/compute ATN of FACC 
/round FACC 

/cUasolute value of FACC 
/test sign of FACC 
/compare FACC with MEM 
/generate random floating point number 



/move RAM MEM to ARG 
/move ROM MEM to ARG 
/move RAM MEM to FACC 
/move ROM MEM to FACC 
/move FACC to MEM 
/move ARG to FACC 
/move FACC to ARG 



7F99 


execute a line 




7F9C 


chrget 




7F9F 


chrgot 




7FA2 


chkcom 




7FA5 


fnttnum 




7FA8 


getadr 




7FAB 


g^tnum 




7FAE 


getbyt 




7FB1 


plsv 




Graphic 


Jun^ Table 




8000 


init 


Graphics BASIC init {same as command^O) 


8002 


parse 


Graphics BASIC command parser 


8004 


start 


' commands 


8006 


screendef 


1 


8008 


screenopen 


2 


800A 


sere enclose 


3 


800C 


sere endear 


•4 


800E 


screen 


•5 


8010 


setpen 


•6 


8012 


setpalette 


7 


8014 


setdmode 


8 


8016 


setdpat 


■9 


8018 


line 


■10 


801A 


box 


•11 


801C ■ 


circle 


•12 


801E 


polygon 


•13 


8020 


ellipse 


•14 


3022 


viewpclr 


15 


8024 


copy 


•16 


8026 


cut 


17 


8023 


paste 


•18 


802A 


load 


•19 


802C 


char 


•20 


802E 


viewportdef 


•21 



System Specification for C65 



Fred Bowen 



March 1^ 1991 



3.4,4 C64DX SOFT VECTORS 

[*** THE FOLLOWING VECTORS AND JUMP TABLES ARE NOT FINAL ***] 
BASIC indirect vectors 



02F7 jmp USR 

02FC esc_fn_vec 

02FE graphic vector 

0300 ierror ~ 

0302 imain 

0304 icrnch 

0306 iqpXop 

0308 igone 

030A ieval 

030C xesclk 

030E iescpr 

0310 iescex 

Kernel indirect vectors 

02FA iAutoScroll 



0312 
0314 
0316 
0318 
031A 
031C 
031E 
0320 
0322 
0324 
0326 
0328 
032A 
032C 
032E 
0330 
0332 



itime 

iirq 

ibrk 

initti 

iopen 

iclose 

ichkin 

ickout 

iclrch 

ibasin 

ibsout 

istop 

igetin 

iclall 

exmon 

iload 

isave 



;USR vector (must be set by application) 

; Escape Function vector 

/Graphic Kernel vector 

/indirect error {output error in ,x) 

/indirect main (system direct loop) 

/indirect crunch (tokenization routine) 

/indirect list (char list) 

/indirect gone (char dispatch) 

/indirect eval (symbol evaluation) 

/escape token crunch 

/escape token list 

/escape token execute 



/AutoScroll used by BASIC, Monitor, Editor 

/ (unused) 
/ IRQ 
/BRK 

;NMI 



/Monitor command indirect 



Editor indirect vectors to routines & tables 



0334 

0336 

0338 

033A 

033C 

033E 
33E 
340 
342 
344 
34 6 
348 



ctlvec 
shfvec 
escvec 
keyvec 
keychk 
decode 



'contrl' characters * 

' shif td' characters 

' escape' characters 

post keyscan, pre-evaluation of keys 

post-evaluation, pre-buffering of keys 

vectors to 6' keyboard matrix decode tables 

- Mode 1 — > normal keys 

~> <SHrFT> keys 

— > <C=^> keys 

— > <CON'rROL> keys 

— > <CAPS LOCK> keys 

— > <ALT> keys 



- Mode 

- Mode 

- Mode 

- Mode 

- Mode 



System Specification for CSS Fred Bowen March 1, 1991 



3.4.5 KERNEL DOCDMENTATION 



C64DX KERNEL JUMP TABLE 

(PRELIMINARY) 



by 
Fred Bowen 



The KERNEL is the ROM resident operating system of the Commodore 
64DX computer. All input, output, and memory management is 
controlled by the KERNEL. The KERNEL JUMP TABLE provides a 
standardized interface to many useful routines within the 
operating system. Application programmers^ are encouraged to 
utilize the JUMP TABLES to simplify their operations and 
guarantee their functionality should hardware or ,, software 
modifications to the system become necessary. 



System Specification for C65 Fred Bo«en March 1, 1991 

C64DX KERNEL JUMP TABLE „ 

DESCRIPTIONS ^f?®. ^3 

preliminary 

B. CBM STANDARD KERNEL CALLS 



CBM Itt^t''^ ^^f^®"' S^^^^ comprise the set of standard 
CBM system calls for the C64 class of machines 
including the PLUS-4. Several of the calls, hSweve? 
Sff e^^n^ ^rr^^^ differently or may requi« s!xgh?!y 
s^fcfJic fttl'^lL ^5^^u"^^ necessary to accomodate 
^n?»if ■ S®^^''''®^..^^ ^^« system, notably the 40/80 
column windowing Edrtor and banked memory facilities As 

SFF^ J,li K^^^"^^ f^^^^' ^^^ ^y^^^"^ configuration (BANK 
5FF) must be m context at the time of the call. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUWP TABLE 
DESCRIPTIONS 



Page 1 
preliminary 



1. $FF81 CINT /initialize screen editor 
Preparation: 

Registers : none 



Memory: 
Flags : 
Calls: 
Results : 

Registers: 

Memory : 

Flags: 

Example : 

SEX 

JSR $FF81 

CLI 



system map 

none 

none 



A used 
X used 
Y used 



init Editor RAM 
init Editor I/O 



none 



/initialize screen editor 



CINT is the Editor's initialization routine. Editor 

indirect vectors installed, programmable key 

definitions assigned, and the ASC/DIN key scanned for 

NATIONAL keyboard/charset determination. CINT sets 

the VIC bank, VIC nybble bank, enables the character 

ROM, resets SID volume, and clears the screen. 

The only thing it does not do that pertains to the Editor 

is I/O initialization, 

which is is needed for IRQs (keyscan, VIC cursor 

blink, split screen modes), key lines, screen 

background colors, etc. (see lOINIT) . Because CINT 

updates Editor indirect vectors that are use4 during 

IRQ processing, you should disable IRQs prior to 

calling it. CINT utilizes the status byte INIT_STATUS 

as follows: 



$1104 bit 6=0 --> 



= 1 --> 



Full initialization. 
(set INIT_STATUS bit 6) 

Partial initialization, 
(not keymatrix pointers) 
(not program key definitions) 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 2 
preliminary 



2. $FF84 lOINIT ; init I/O devices 



Preparation : 




Registers : 


none 


Memory : 


system map 


Flags ; 


none 


Calls: 


none 


Results : 




Registers: 


.A used 
.X used 
.Y used 


Memo ry : 


initialize I/O 


Flags: 


none 


Example : 




SEI 

JSR 5E?84 

CLI 


/initialize sy 



lOINIT IS perhaps the major function of the Reset 
handler. It initializes both CIA's (timers, keyboard, 
SS''^r^LS°''*^^ ''?®'' port), the 4510 port, the VIC chip. 
The UART and the DOS. It distinguishes a PAL system 
from an NTSC one and sets PALCNT if PAL. The system IRQ 
source, the VIC raster, is started (pending IRQs are 
cleared) . lOlNIT utilizes the status byte INIT STATUS 
as follows: — 

$1104 bit 7 = — > Full initializatibn. 

(set INIT_STATUS bit 7) 

= 1 — > Partial initialization. 

You should be sure IRQs are disabled before calling 
lOINIT to avoid interrupts while the various I/O 
aevxces are being initialized. 



System Specification for C65 



Fred Bowen 



March L, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 3 
preliiriinary 



3. 5FF87 RAMTAS ; init RAM and buffers 



Preparation: 

Registers : 
Memory : 
Flags: 
Calls: 



none 

system map 
none 
none 



Results: 

Registers: 

Memory : 
Flags: 



.A used 
.X used 
.Y used 

initializes RAM 

none 



Example: 

JSR $FF87 /initialize system RAM 



RAMTAS clears all base page RAM, allocates the 

sets pointers to the top 

and bottom of system RAM and points the 

SYSTEM_VECTOR to BASIC cold start. 

Lastly it sets a flag, DEJAVU, to indicate to 

other routines that system RAM has been initialized 

and that the SYSTEM_VECTOR is valid. It should be 

noted that the C64DX RAMTAS routine does NOT in any 

way test RAM. 



System Specification for C65 

C64DX KERMEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 4 

preliminary 



4. $FF8A RESTOR 



;init Kernel indirects 



Preparation: 




Registers : 


none 


Memory ; 


system map 


Flags: 


none 


Calls: 


none 


Results ; 




Registers : 


.A used 
.X used 
.Y used 


Memory : 


kernel ind 


Flags: 


none 


Example : 




SET 

JSR $B?8A 

CLI 


; restore k 



RESTOR restores the default values of all the Kernel 
indirect vectors from the Kernel ROM list. It does 
NOT affect any other vectors, such as those used by 
the Editor (see CINT) and BASIC. Because it is 
possible for an interrupt (IRQ' or NMI) to occur 
during the updating of the interrupt indirect 
vectors, you should disable interrupts prior to 
calling RESTOR. See also the VECTOR call. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 5 
preliminary 



5. $FF8D VECTOR 



;init or copy indirects 



Preparation: 

Registers 

Memory: 
• Flags: 

Calls: 



.X = adr <low) of user list 
-Y - adr (high) of user, list 

system map 

.C = — > load Kernel vectors 
■C = 1 — > copy Kernel vectors 

none 



Results : 

Registers 

Memory : 
Flags: 



-A used 
.Y used 

as per call 

none 



Example : 



LDX #save_lo 
LDY #save hi 
SEC ~ 
JSR 5FF87 



;copy indirects to 'save' 



VECTOR reads or writes the Kernel RAM indirect 
vectors. - Calling VECTOR with the carry status set 
stores the current contents of the indirect vectors 
to the RAM address passed in the .X and .Y registers 
(to the current RAM bank) . Calling VECTOR with the 
carry status clear updates the Kernel indirect 
vectors from the user list passed in the .X and .Y 
registers (from the current RAM bank) . Intierrupts 
(IRQ and NMI) should be disabled when updating the 
indirects. See also the RESTOR call. 



System Specification for C65 

"C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 6 
preliminary 



6. $FF90 SETMSG 



; kernel messages on/off 



Preparation: 

Registers; .A = message control 

Memory: system map 

Flags : none 

Calls: none 

Results: 

Registers: none 

Memory: MSGFLG updated 

Flags: none 



Exampl e : 



LDA #0 
JSR SFF90 



;turn OFF all Kernel messages 



SETMSG updates the Kernel message flag byte MSGFLG 
which determines whether system error and/or 
control messages will be displayed. BASIC normally 
disables error messages always and disables control 
messages m 'run' mode. Note that the Kernel error 
messages are not the verbose ones printed by BASIC, 
but simply the 'I/O ERROR #' message that you see 
when in the Monitor, for example. Examples of Kernel 
control messages are 'LOADING' and 'FOUND' 
The MSGFLG control bits are: 

MSGFLG bit 7=1 — > enable CONTROL messages 
bit 6=1 — > enable ERROR messages 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE Page 7 

DESCRIPTIONS preliminary 

7. $FF93 SECND /serial: send SA after LISTN 

Preparation: 

Registers: .A = SA (secondary address) 

Memory: system map 

Flags: none 

Calls: LISTN 

Results: 

Registers: .A used 

Memory: STATUS ($90) 

Flags: none 

Example: 

LDA #8 

JSR SFFBl ; LISTN device 8 

LDA #15 

JSR $FF93 .-pass it SA #15 

? 

SECND is a low-level serial routine used to send a 
secondary address (SA) to a LISTNing device (see 
LISTN Kernel call) . An SA is usually used to provide 
setup information to a device before the actual data 
I/O operation begins. Attention is released after a 
call to SECND. SECND is not used to send an SA to a 
TALKing device (see TKSA) . (Most applications should 
use the higher level I/O routines; see OPEN and 
CKOUT) . 



System Specification for t65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 8 
preliminary 



8. SFF96 TKSA /serial: send SA after TALK 



Preparation: 

Registers: 
Memory: 
Flags: 
Calls: 



.A = SA (secondary address) 

system map 

none 

TALK 



Results : 

Registers t 

Memory : 
Flags: 



•A used 
STATUS ($90) 
none 



Example : 



LDA #8 
JSR $FFB4 
LDA #15 
JSR $i.r93 



;TALK device 8 
;pass it SA #15 



TKSA is a iow-level serial routine used to send a 

secondary address (SA) to a device commanded to TALK 

(see TALK Kernel call) . An SA is usually used to 

provide setup information to a device before the 

actual data I/O operation begins. (Most applications 

^ 2"iS.,.?f® ^^^ higher level I/O routines; see OPEN 
and CHKIN) . 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bow en 



March 1, 1991 



Page 9 
preliminary 



9. $FF99 MEMTOP 



; set/read top of sysl;em RAM 



Preparation: 

Registers 

Memory : 
Flags : 

Calls: 



.X = Isb of MEMSIZ 
.X =* msb of MEMSIZ 

system map 

.C = — "> set top of memory 
■C = 1 — > read top of memory 

none 



Results: 




Registers: 


.X - Isb of MEMSIZ 
.Y - msb of MKMSIZ 


Memory; 


MEMSIZ 


Flags: 


none 


Example : 





SEC 

JSR $FF99 ;get top of user RAM 

DEY 

CLC 

JSR $FF99 ; lower it 1 block 



MEMTOP is used to read or set the top of system RAM, 
pointed to by MEMSIZ. This call is included in 
the C64DX for completeness, but neither the Kernel nor 
BASIC utilize MEMTOP as it has little meaning in the 
banked memory environment of the computer (even the 
RS-232 buffers are permanently ail*ocated) . 
None-the-less, set the carry status to load MEMSIZ 
into ,X and .Y, and clear it to update the pointer 
from -X and .Y. Note that MEMSIZ references only 
system RAM, The Kernel initially sets MEMSIZ 
to $FFOO, 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 10 
preliminary 



10. $FF9C MEMBOT 



; set/read bottom of system RAM 



Preparation: 

Registers 

Memory : 
Flags: 

Calls: 



.X = Isb of MEMSTR 
.Y = msb of MEMSTR 

system map 

,C = — > set bot of memory 
.C 5= 1 — > read bot of memory 

none 



Results: 

Registers 

Memory ; 
Flags : 



.X = Isb of MEMSTR 
.Y = msb of MEMSTR 

MEMSTR 

none 



Example: 



SEC ' 

JSR $FF9C 

INY 

CLC 

JSR $FF9C 



;get bottom of user RAM 



; raise it 1 block 



MEMBOT is used to read or set the bottom of system 
RAM, pointed to by MEMSTR. This call is 
included in the C64DX for completeness, but neither 
the Kernel nor BASIC utilize MEMBOT as it has little 
meaning in the banked memory environment of the C64DX. 
None-the-less, set the carry status to lodd MEMSTR 
into .X and .Y, and clear it to update the pointer 
from .X and .Y. Note that MEMSTR references only 
system RAM. The Kernel initially sets MEMSTR 
to $2000 (BASIC text starts here) . 



System Specification for CSS 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 11 
preliminary 



11. SFF9F KEY ;scan keyboard 

Preparation: 

Registers : none 
Memory: system map 
Flags ; none 
• Calls: none 



Results : 

Registers : none 
Memory : 

Flags : none 



keyboard buffer 
keyboard flags 



Example: 

JSR $FF9F ;scan the keyboard 



KEY is an Editor routine which scans the entire 
keyboard. It distinguishes between shifted and unshifted 
keys, control keys, and programmable 
keys, setting keyboard status bytes and managing the 
keyboard buffer. After decoding the key, KEY will 
manage such features as toggling cases, pauses or 
delays, and key repeats. It is normally called by the 
operating system during the 6OH2 IRQ processing. Upon 
conclusion, KEY leaves the. keyboard hardware driving 
the key-line on which the STOP key is located- 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE Paae llA 

DESCRIPTIONS preliminlry 

There are two indirect RAM jumps encountered during a 
keyscan: KEYVEC ($33A) and KEYCHK ($33C) . KEYVEC 
(alias KEYLOG) is taken whenever a key depression is 
discovered/ before the key in .A has been decoded. 
KEYCHK is taken after the key has been decoded, just 
before putting it into the key buffer- KEYCHK carries 
the ASCII character in .A, the keycode in .Y, and the 
shift-key status in ,X, 

The keyboard decode matrices are addressed via 
indirect RAM vectors as well, located at DECODE. 



System 


Specification 


for 


C65 


Fred Bowen' 




C&40X KERNEL 
DESCRIPTIOKS 


JUMP 


TABT.F. 






12. SFFA2 


SETTMO 


; (reserved) 








Preparation: 










Registers : none 








Memory: 


system map 








Flags; 


none 








Calls: 


none 



March 1, 1991 



Results: 




Registers : 


none 


Memory : 


TIMOUT 


Flags : 


none 


Example: 




LDA #value 
JSR SFFA2 


;updat 



Page 12 
preliminary 



; update TJMOUT byte 



SETTMO is unused in the C64DX and is included for 

compatibility and completeness. It is used in the C64 

by the IEEE communication cartridge to disable I/O 
timeouts . 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



13. $FFA5 ACPTR 



Page 13 
preliminary 



; serial: byte input . 



Preparation: 

Registers: 
Memory : 
Flags: 
Calls: 



none 

system map 

none 

TALK 

TKSA (if necessary; 



Results : 

Registers: 
Memory : 
Flags: 



.A = data byte 
STATUS ($90) 
none 



Example : 



JSR 5FFA5 
STA data 



; input a byte from serial bus 



ACPTR IS a low-level serial I/O utility to accept a 
sa.ngle byte from the current serial bus TALKer using 
full handshaking. To prepare for this routine a 
device must first have been established as a TALKer 
(see TALK) and passed a secondary address if 
necessary (see TKSA). The byte is returned in .A. 
(Most applications should use the higher level I/O 
routines; see BASIN and GETIN) . 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 14 
preliminary 



14. $FFAS CIOUT 



/serial: byte output 



Preparation: 

Registers: 
Memory: 
Flags: 
Calls: 



,A = data byte 

system map 

none 

LISTN 

SECND {if necessary) 



Results : 

Registers: 

Memory: 

Flags: 



.A used 
STATUS ($90) 
none 



Example : 



LDA data 
JSR SFFA8 



;send a byte via serial bus 



CIOUT is a low-level serial I/O utility to transmit a 
single byte to the current serial bus LISTNer using 
full handshaking. To prepare for this routine a 
device must first have been established as a LISTNer 
(see LISTN) and passed a secondary address if 
necessary (see SECND) . The byte is passed in .A. 
Serial output data is buffered by one character, with 
the last character being transmitted with EOI after a 
call to UNLSN. (Most applications should use the 
higher level I/O routines; see BSOOT) . 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



15. $FFAB UNTLK 



Fred Bowen 



March 1, 1991 



Page 15 
preliminary 



; serial: send untalk 



Preparation: 

Registers : 
Memory : 
Flags: 
Calls: 



none 

system map 
none 
none 



Results : 

Registers: 

Memory: 

Flags: 



.A used 
STATUS ($90) 
none 



Example: 

JSR $FFAB ;UNTALK serial device 

UNTLK is a low-levll Kernel serial bus routine that 
sends an UNTALK command to all serial bus devices It 
commands all TALKing devices to stop sending data. 
(Most applications should use the higher level I/O 
routines; see CLRCH) . 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 16 
preliminary 



16. $FFAE UNLSN 



/serial: send unlisten 



Preparation: 

Registers: 
Memory : 
Flags: 
Calls: 



none 

system map 
none 
none 



Results : 

Registers : 
Memory : 
Flags: 



.A used 
STATUS ($90) 
none 



Exaiftple: 

JSR $FFAE ; UNLISTEN serial device 



UNLSN is a low-level Kernel serial bus routine that 
sends an UNLISTEN command to all serial bus devices. 
It commands all LISTENing devices to stop reading 
data. (Most applications should use the higher level 
I/O routines; see CLRCH) . 



System Specification for CSS 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



17. $FFB1 LISTN 



Fred Bowen 



March X, 1991 



Page 17 
preliininary 



; serial: send listen command 



Preparation: 

Registers : 
Memory: 
Flags: 
Calls: 



.A =* device (0-31) 

system map 

none 

none 



Results: 

Registers : 
Memory : 
Flags: 



.A used 
STATUS ($90) 
none 



Example : 

JSR $FFBl ; command device to LISTEN 

LISTN is a low-levll Kernel serial bus routine that 
sends an LISTEN command to the serial bus device in 
,A. It commands the device to start reading data. 
(Most applications should use the higher level I/O 
routines; see CKOUT) . 



System Specification for C6S 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 18 
preliminary- 



IB. $FFB4 TALK ; serial; send talk command 



Preparation: 

Registers: 
Memory : 
Flags: 

Calls: 



.A « device (0-31) 

system map 

none 

none 



Results ; 

Registers : 
Memory : 
Flags: 



.A used 
STATUS ($90) 
none 



Example : 

JSR $FFB4 /command device to TALK 



TALK is a low-level Kernel serial bus routine that 
sends an TALK command to the serial bus device in .A. 
It commands the device to start sending data. (Most 
applications should use the higher level , I/O 
routines; see CHKIN) . 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



19. $FFB7 READSS 



Fred Bowen 



March 1, 1991 



Page 19 

preliminary 



;read I/O status byte 



Preparation: 

Registers : none 

Memory: system map 

Flags: none 

Calls: none 

Results : 

Registers: .A « STATUS ($90 or $A6) 

Memory: STATUS cleared if RS-232 ($A6) 

Flags: none 



Example: 

JSR SFFB7 ; STATUS for last I/O 

READSS {alias RL^ST) returns the status byte 

n^^R^?^.? ''^S^ ^^J ^^^^ ^/° operation (serial 

^ ?'^H^ performed. Serial bus and newDOS devices 
update STATUS ($90} and RS-232 I/O aevices 

^fff%^SSTAT,($A6). Note that, to simulate an 
6551, RSSTAT is cleared after it is read via READSS, 
The Ijst I/O operation is determined by the contents 
or kA (5BA) , thus applications which drive I/O 
uinilDSs!"''^ ""^^ lower-level Kernel calls should not 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 20 
preliminary 



20. $FFBA SETLFS 



;set channel LA, FA, SA 



Preparation: 



Registers: .A *= LA (logical #) 
.X = FA (device #) 
.Y = SA (secondary adr] 



Memory : 


system map 


Flags: 


none 


Calls: 


none 


Results : 




Registers : 


none 


Memory: 


LA, FA, SA updated 


Flags: 


none 


Example: 




see OPEN 





SETLFS sets the logical file number (LA, $B8) , device 
number (FA, $BA) , and secondary address (SA, $B9) for 
the higher-level Kernel I/O routines. The LA must be 
unique among OPENed files and is used to identify 
specific files for I/O operations. The device number 
range is to 31 and is used to target I/O. The SA is 
a command to be sent to the indicated device, usually 
to place it in a particular mode. If the SA is not 
needed, the .Y register should pass $FF. SETLFS is 
often used along with SETNAM and SETBNK calls prior 
to OPENS, See the Kernel OPEN, LOAD, and SAVE calls 
for examples . 



System Specification for C65 

C64DX KEBNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 21 
preliminary 



21. $FFBD SETNAM 



;set filename pointers 



Preparation: 




Registers: 


.A - string length 
.X = string adr low 
.Y = string adr_high 


Memory: 


system map 


Flags : 


none 


Calls: 


SETBNK 


Results : 




Registers: 


none 


Memory: 


FNLEN, FNADR updated 


Flags: 


none 


Example: 




see OPEN 





SETNAM sets up the filename or command string for 
higher-level Kernel I/O calls such as OPEN, LOAD, and 
SAVE, The string (filename or command) length is 
passed m .A and updates FNLEN ($B7) . The- address of 
the stri-ng is passed in .X (low) and .Y (high). See 
the companion call, SETBNK which specifies which RAM 
bank the string is found. If there is no string, 
SETNAM_ should still be called and a null (SOO) length 
specified (the address does not matter) . SETNAM is 
often used along with SETBNK and SETLFS calls prior 
to OPENS. See the Kernel OPEN, LOAD, and SAVE calls 
for examples. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



22. $FFCO OPEN ;open logical file 



Page 22 
prelirainary 



Preparation; 

Registers : 
Memory ; 
Flags : 
Calls: 



none 

system map 

none 

SETLFS, SETNAM, SETBNK 



Results; 

Registers 

Memory: 

Flags; 



Example: 



,A = error code (if ciny) 
.X used 
.Y used 

setup for I/O 

STATUS, RSSTAT updated 

.C = 1 — > error 



OPEN 1,8, 15, "10" 



LDA llength ' ; f nlen 

LDX #<f ilename ; fnadr (command) 

LDY #>filename 





JSR 


$FFBD 


; SETNAM 




- 


LDX 
JSR 


#0 
$FF68 


; f nbank 
; SETBNK 


(RAM_0 




LDA 
LDX 
LDY 
JSR 


#1 
#8 
#15 
$FFBA 


;la ■ 

;fa 

;sa 

; SETLFS 






JSR 


$FFCO 


; OPEN 






BCS 


error 






filename 
length 


.BYTE '10' 
= 2 







System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE Paae 22A 

DESCRIPTIONS preliminary 

OPEN prepares a logical file for I/O operations. It 
creates a unique entry in the Kernel logical file 
tables LAT <$362), FAT ($36C) , and SAT ($376) using 
its index LDTND ($98) and data supplied by the user 
via SETLFS. There can be up to ten logical files 
OPENed simultaneously. OPEN performs device specific 
opening tasks for serial, RS-232, keyboard & screen, 
devices, including clearing the previous status and 
transmitting any given filename or command string 
supplied by the user via SETNAM and SETBNK. The I/O 
status will be updated appropriately and can be read 
via READSS, 

The path to OPEN is through an indirect RAM vector at 
331A. Applications may therefore provide their own 
OPEN procedures or suppliment the system's by 
re-directing this vector to their own routine. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bow en 



March 1, 1991 



Page 23 
preliminary 



23. $FFC3 CLOSE 



; close logical file 



Preparation: 




Registers: 


.A = LA (logical #) 


Memory: 


system map 


Flags: 


.C (see text below) 


Calls: 


none 


Results: 




Registers: 


.A = error code (if any) 
.X used 
.Y used 


Memory: 


logical tables updated 
STATUS, RSSTAT updated 


Flags: 


.C = 1 — > error 


Example: 




LDA #1 
JSR SFFC3 
BCS error 


;la 
; CLOSE 



CLOSE removes the logical file (LA) passed in .A from 
the logical file tables and performs device specific 
closing tasks. Keyboard, screen^ and any unOPENed 
files pass through. RS-232 devices are not closed 
until all buffered data has been transmitted. 
Serial files are 

closed by transmitting a 'close' command (if an SA 
was given when it was opened), sending any , buffered 
character, and UNLSTNing the bus. 

There is a special provision incorporated into the 
CLOSE routine of systems featuring BASIC DOS command. 
If the following conditions are all TRUE, a full 
CLOSE is NOT performed: the table entry is removed 
but a 'close' command is NOT transmitted to the 
device. This allows the disk command channel to be 
properly OPENed and CLOSEd without the disk operating 
system closing ALL files on its end: 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 

Page 23A 

preliminary 



.C = 1 — > indicates special CLOSE 
FA >-8 — > device is a disk 
SA = 15 — > command channel 

The path to CLOSE is through an indirect RAM vector 
at $31C, Applications may therefore provide their own 
CLOSE procedures or suppliment the system's by 
re-directing this vector to their own routine. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 24 
preliminary 



24. $FFC6 CHKIN ;set input channel 
Preparation: 

Registers: .X = LA (logical #) 
Memory: system map 
Flags: none 
Calls : OPEN 



Results: 



Registers: .A = error code (if any) 
.X used 
.Y used 

Memory: LA, FA, SA, DFLTN 

STATUS, RSSTAT updated 



Flags : 


.C = 1 


Example; 




LDX #1 


;la 


JSR $FFC6 


; CHKIN 


ECS error 





CHKIN establishes an input channel to the device 
associated with the logical address (LA) passed in 
.X, in preparation for a call to BASIN or GETIN. The 
Kernel variable DFLTN ($99) is updated to indicate 
the current input device and the variables LA, FA, 
and SA are updated with the file's parameters from 
its entry in the logical file tables (put there by 
OPEN). CHKIN performs certain device specific tasks: 
screen and keyboard channels pass through, and serial 
channels are sent a TALK command and the SA transmitted 
(if necessary) . Call CLRCH to restore normal I/O 
channels , , 

CHKIN is required for all input except the keyboard. 
If keyboard input is desired and no other input 
channel is established, you do not need to call CHKIN 
or OPEN. The keyboard is the default input device for 
BASIN and GETIN. 

The path to CHKIN is through an indirect RAM vector 
at $31E. Applications may therefore provide their own 
CHKIN procedures or suppliment the system's by 
re-directing this vector to their own routine. 



System Specification for C65 

C64DX KERNEL J^JMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 25 
preliminary 



25. $FFC9 CKOUT ;set output channel 
Preparation: 

Registers: .X = LA {logical #) 

Memory: system map 

Flags: none 

Calls: OPEN 
Results : 



Registers; 



Memory 



.A = error code (if any) 
*X used 
.Y used 

LA, FA, SA, DFLTO 
STATUS, RSSTAT updated 

,0=1 — > error 



Flags: 

Example: 

LDX #1 ;la ■ 
JSR $FFC9 ; CKOUT 

BCS error 

y 

CKOUT establishes an output channel to the device 
associated with the logical address (LA) passed in 
.X, in preparation for a call to BSOUT. The Kernel 
variable DFLTO ($9A) is updated to indicate the 
current output device and the variables LA, FA, and 
SA are -updated with the file's parameters from its 
entry in the logical file tables (put there by OPEN) . 
CKOUT performs certain device specific tasks: 
keyboard channels are illegal, screen channels pass 
through, and 

serial channels are sent a LISTN command and the SA 
transmitted (if necessary). Call CLRCH tg restore 
normal I/O channels. 

CKOUT is required for all output except the screen. 
If screen output is desired and no other output 
channel is established, you do not need to call CKOUT 
or OPEN. The screen is the default output device for 
BSOUT. 

The path to CKOUT is through an indirect RAM vector 
at $320. Applications may therefore provide their own 
CKOUT procedures or suppliment the system's by 
re-directing this vector to their own routine. 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE Pace 26 

DESCRIPTIONS preliminary 

26. $FFCC CLRCH /restore default channels 

Preparation: 

Registers: none 

Memory: system, map 

Flags : none 

Calls: none 

Results : 

Registers: .A used 
.X used 

Memory: DFLTI, DFLTO updated 

Flags: none 

Example: 

JSR $FFCC /restore default I/O 

CLRCH (alias CLRCHN) is used to clear all open 
> channels and restore the system default I/O channels 
after other channels have been established via CHKIN 
and/or CHKOUT. The keyboard is the default input 
device and the screen is the default output device. 
If the input channel was to a serial device, CLRCH 
first UNTLKs it. If the output channel was to a 
serial device, it is UNLSNed first. 

The path to CLRCH is through an indirect RAM vector 
at $322. Applications may therefore provide their own 
CLRCH pro cedures or suppliment the system' s by 
re-directing this vector to their own routine?. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 27 
preliminary 



27. $FFCF BASIN 



; input from channel 



Preparation: 

Registers: 
Memory: 
Flags: 
Calls: 



none 

system map 

none 

CHKIN (if necessary) 



Results: 

Registers: 

Memory: 

Flags: 



.A = character (or error code) 
STATUS, RSSTAT updated 
.C = 1 if error 



Exampl e : 

LDY #0 ; index 

more JSR SFFCF ; input a character 

STA data,y ;buffer it 
INY ' 

CMP #$0D ;carrage return? 
BNE more 



BASIN (alias CHRIN) reads a character from the 
current _input device (DFLTN $99) and returns it in 
,A. Input from devices other than the keyboard (the 
default input device) must be OPENed and CHKINed. The 
character is read from the input buffer associated 
with the current input channel: 



System Specification for C65 Fred Bowen March 1, 1991 

C54DX KERNEL JUMP TABLE Page 27A 

DESCRIPTIONS preliminary 

1. RS-232 data is returned a character at a time 
from, the RS-232 input buffer, waiting 

until a character is received if necessary. If 
RSSTAT is bad from a prior operation, 
input is skipped and null input (carrage return) 
is substituted, 

2. Serial data is returned a character at" a time 
directly from the serial bus, waiting until a 
character is sent if necessary. If STATUS ($90) 
is bad from a prior operation, input is skipped 
and null input (carrage return) is substituted. 

3. Screen data is read from screen RAM starting at 
the current cursor position and ending with a 
faked carrage return at the end of the logical 
screen line. 

4. Keyboard data is input by turning on the cursor, 
reading characters from the keyboard buffer and 
echoing them on the screen until a carrage return 
is encountered. Characters are then returned one 
at a time from the screen until all characters 
input have been passed, including the carrage 
return. Any calls after the eol will start the 
process over again. 

The path to BASIN is through an indirect RAM vector 
at $324, Applications may therefore provide their own 
? BASIN procedures or suppliment the system's by 
re-directing this vector to their own routine. 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE Pace 28 

DESCRIPTIONS preliminary 

28. $FFD2 BSODT /output to channel 
Preparation: 

Registers: .A 's character 

Memory: system map 

Flags: none 

Calls: CKOUT (if necessary) 
Results: 

Registers: .A = error code (if any) 

Memory: STATUS, RSSTAT updated 

Flags: .C = 1 if error 
Example: 

LDA tcharacter 

JSR SFFD2 /output a character 

BSOUT {alias CHROUT) writes the character in .A to 
the current output device (DFLTO $9A) . Output to 
devices other than the screen (the default output 
device) must be C^Ned and CKOUTed. The character is 
written to the output buffer associated with the 
current output channel: 

1. RS-232 data is put a character at a time into the 
RS-232 output buffer, waiting until there 
is room if necessary. 

3. Serial data is passed to CIOUT which buffers one 
character and sends the previous character. 

4. Screen data is put into screen RAM at th^ current 
cursor position, 

5. Keyboard output is illegal. 

The path to BSOUT is through an indirect RAM vector 
at $326. Applications may therefore provide their own 
BSOUT procedures or supplement the system's by 
re-directing this vector to their own routine. 



L 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 29 
preliminary 



29. SFFD5 LOAD /load from file 
Preparation: 

Registers : 



.A ^ —> LOAD 

.A > — > VERIFY 

.X = load adr_lo (if SA^O) 

.y = load adr_hi (if SA«0) 

Memory: system map 

Flags: none 

Calls: SETLFS, SETNAM, SETBNK 



Results : 

Registers 

Memory : 
Flags: 



.A = error code (if any) 
,X = ending adr_lo 
,Y = ending adr_hi 

per command 
STATUS updated 

-C = i — > error 



Example : 



LOAD "program", 8, 1 



filename 
length 



LDA #length 
LDX #<filename 
LDY #>filename 
JSR $FFBD 

LDA #0 
LDX #0 

JSR $FF68 

LDA #0 
LDX #8 
LDY #SFF 
JSR SFFBA 

LDA #0 

LDX #<load adr 
LDY #>load~adr 
JSR $FFD5 
BCS error 
STX end lo 
STY end_hi 

.BYTE 'program' 
= 7 



;fnlen 
; f nadr 

; SETNAM 

; load/verify bank (RAM 0) 
;fnbank (RAM 0) ~ 
; SETBNK 

; la (not used) 
; fa , 

;sa (SA>0 normal load) 
; SETLFS 

; load, not verify 
; (used only if SA=0) 
; (used only if SA=0) 
;LOAD 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE paoe 29A 

DESCRIPTIONS preliminary 

This routine LOADs data from an input device into 

memory. It can also be used to VERIFY that data 

in memory matches that in a file. LOAD performs 

device specific tasks for serial LOADs. 

You cannot LOAD from RS-232 devices, the screen, or 

the keyboard. While LOAD performs all the tasks of an 

OPEN, it does NOT create any logical files as an OPEN 

does. Also note that LOAD cannot 'wrap' memory banks. 

As with any I/O, the I/O status is updated 

appropriately and can be read via READSS. LOAD has 

two options that the user must select: 

1. LOAD vs. VERIFY: the contents of .A passed at the 
call to LOAD determines which mode is in effect. 
If ,A is zero, a LOAD operation will be performed 
and memory will be overwritten. If .A is 
non-zero, a VERIFY operation will be performed 
and the result passed via the error mechanism. 

2. LOAD ADDRESS: the secondary address (SA) setup by 
the call to SETLFS determines where the LOAD 
starting address comes from. If the SA is zero, 
the user wants the address in .X and .Y at the 
time of the call to be used. If the SA is 
non-zero, the LOAD starting address is read from 
the file header itself anii the file loaded to the 
same place from which it was SAVEd. 

The serial LOAD routine automatically attempts to 
access a newDOS drive^ then attempts 

to BURST load a file, and resorts to the normal load 
mechanism (but still using the FAST serial routines) 
if the BURST handshake is not returned. 

The path. to LOAD is through an indirect RAM vector at 
$330. Applications may therefore provide their own 
LOAD procedures or suppliment the system' s by 
re-directing this vector to their own routine. 



System 


Specification for C65 Fred Bowen March l, 1991 




C64DX KERNEL JUMP TABT.F: 
DESCRIPTIONS 




Page 30 
preliminary 




30. $FFD8 SAVE ;save to file 






Preparation: 








Registers: 


.A 
.X 
.Y 


= pointer to start adr 
- end_adr_lo 
= end_adr_hi 




Memory : 


system map 




Flags : 


none 




Calls: 


SETLFS, SETNAM, SETBNK 




Results: 








Registers: 


.A 
.X 
.Y 


= error code {if any) 
= used 
= used 




Memo ry : 


STATUS updated 




Flags: 


.C 


= 1 — > error 




Example : 


SAVE "program", 8 




LDA # length 
> LDX #<filename 

LDY #>filename 
JSR $FFBD 


;fnlen 
; f nadr 

; SETNAM 




LDA #0 
LDX #0 
JSR $FF68 




;save from bank {RAM 0) 
;fnbank (RAM 0) 
; SETBNK 




LDA #0 
LDX #8 
LDY #0 
JSR $FFBA 




;la (not used) 

;fa 

;sa (cassette only) 

; SETLFS 




LDA #start 
LDX end 
LDY end+1 
JSR $FFD8 
BCS error 




/pointer to start address 
/ending address lo 
/ending adr hi 
;SAVE 



filename .BYTE 'program' 

length - 7 

start .WORD address 1 ;page-0 

end .WORD address2 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABLE Pa„- -sna 

DESCRIPTIONS prelimlnlry 

This routine SAVEs data from memory to an output 
device. SAVE performs device specific ' tasks for 
serial SAVEs. You cannot SAVE from 
RS-232 devices, the screen, or the keyboard. While 
SAVE performs all the tasks of an OPEN, it does NOT 
create any logical files as an OPEN does . The 
starting address of the area to be SAVEd must be 
placed in a base-page vector and the • address of this 
vector passed to SAVE in .A at the time of the call. 
The address of the last byte to be SAVEd PLUS ONE is 
passed in .X and .Y at , the same time. 

SAVE first attempts to access a newDOS drive. 

There is no BURST save; the normal FAST serial 

routines are used. As with any I/O, the I/O status 

will be updated appropriately and can be read via 

READSS, 

J^f path to SAVE is through an indirect RAM vector at 
5332. Applications may therefore provide their own 
SAVE procedures or suppliment the system' s by 
re-directing this vector to their own routine. 



System Specification for C65 

C64DX KERNEL JOMP TABLE 
DESCRIPTIONS 



Fred Bow en 



March 1, 1991 



Page 31 
preliminary 



31. $FFDB SETTIM 



;set internal clock 



Preparation: 




Registers: 


,A = hours 
.X == minutes 
-Y s= seconds 
.Z = tenths 


Memory : 


system map 


Flags: 


none 


Calls: 


none 


Results : 




Registers : 


none 


Memory: 


TOD at CIA $DCOO updated 


Flags; 


none 


Example: 




LDA #0 

TAX 

TAY 

TA2 

JSR $FFDB 


; reset clock 
; SETTIM 



SETTIM sets the system CIA 24-hour TOD clock, which 
counts tenths of a second and automatically 
wraps at the 24-hour point. ^ 



System Specification for CSS 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 32 
preliminary 



32. SFFDE RDTIM 



;read internal clock 



Preparation: 






Registers: 


none 




Memory : 


system map 


Flags : 


none 




Calls: 


none 




Results : 






Registers: 


.A = 
.X = 
.Y = 

.Z = 


hours 
minutes 
seconds 
tenths 


Memory : 


none 




Flags: 


none 




Example: 






JSR $E?DE 


; RDTIM 



RDTIM reads the system CIA 24-hour TOD clock, which 
counts tenths of a second. The timer is automaticallv 
wrapped at the 2 4 -hour point. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 33 

preliminary 



33. $FFE1 STOP ;scan stop key 



Preparation: 

Registers : 
Memory : 
Flags : 
Calls: 



none 

system map 

none 

none 



Results : 

Registers 

Memory : 
Flags : 



.A - last keyboard row 
.X =» used (if STOP key) 



none 



status valid 



Example: 



JSR $FFE1 
BEQ stop 



/scan STOP key 
/branch if down 



STOP checks a Kernel variable STKEY ($91), which is 
updated by UDTIM during normal IRQ processing and 
contains the last scan of keyboard column C7. The 
STOP key is bit-7, which will be zero if the key is 
down. If it is, default I/O channels are restored via 
CLRCH and the keyboard queue is flushed by reseting 
NDX (SDO) . The keys on keyboard -line C7 are: 

l>it; 7654 32 10 
key: STOP Q C^ SPACE 2 CTRL <— 1 



The path to STOP is through an indirect RAM vector at 
5328. Applications may therefore provide their own 
STOP_ procedures or suppliment the system's by 
re-directing this vector to their own routine. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 34 

preliminary 



34. $FFE4 GETIN 



;read buffered data 



Preparation: 

Registers: 
Memory: 
Flags: 
Calls: 



none 

system map 

none 

CHKIN (if necessary) 



Results: 

Registers 

Memory: 
Flags: 



.A - character (or error code) 
.X used 
.Y used 

STATUS, RSSTAT updated 

.C = 1 if error 



Example: 

wait JSR $FFE4 
BEQ w€.irt 
STA character 



;get any key 



GETIN reads a character from the current input device 
(DFLTN $99) buffer and returns it in .A* Input from 
devices other than the keyboard (the default input 
device) must be OPENed and CHKINed. The character is 
read from the input buffer associated with the 
current input channel: 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KEimEL JUMP TABLE Page 34A 

DESCRIPTIONS preliminary 

1. Keyboard input: a character is removed from the 
keyboard buffer and passed in .A, If the buffer 
is empty, a null ($00) is returned. 

2. RS-232 input: a character is removed from the 
RS-232 input buffer and passed in .A. If 

the buffer is empty, a null ($00) is returned, 
(use READSS to check validity) . 

3. Serial input: GETIN automatically jumps to BASIN. 
See BASIN serial I/O. 

4. Screen input: GETIN automatically jumps to BASIN. 
See BASIN serial I/O. 

The path to GETIN is through an indirect RAM vector 
at $32A. Applications may therefore provide their own 
GETIN procedures or suppliment the system's by 
re-directing this vector to their own routine. 



? 



System Specification for C65 



Fred Bowen 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



35. $FFE7 CLALL 



March 1, 1991 



Page 35 
preliminary 



; close ail files and channels 



Preparation: 

Registers: 
Memory : 
Flags: 
Calls: 



none 

system map 
none 
none 



Results: 

Registers 

Memory : 
Flags: 



.A used 
.X used 

LDTND, DFLTN, DFLTO updated 
none 



Example: 



JSR $FFE7 ; close files 



CLALL deletes 
reseting the 



all logical file table entries by 
table index, LDTND ($98) , It clears 

SefauJt l%"li" ^'^f "^'" ^" ^"^' ^"^ restores Se 
aerauxt I/O channels vxa CLRCH, 

I!?^^?9r^ i° CLALL is through an indirect RAM vector 

cLll ;r-o?Si^''^^^°''^ "'^^ therefore provide their own 
CLALL procedures or suppliment the system's by 
re-directxng this vector to their own routine 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 36 
preliminary 



36. SFFEA ScanStopKey 

(was UDTIM r which has no purpose on C64DX) 

Preparation; 

Registers : none 

Memory: system map 

Flags: none 

Calls: none 



Results: 

Registers 

Memory : 
Flags: 



.A used 
.X used 

TIME, TIMER, STKEY updated 

none 



Example: 

JSR SFFEA ; ScanStopKey 



scans key line C7, on which the STOP key 

lies, and stores the result in STKEY ($91) . The 

Kernel routine STOP utilizes this variable. 



System Specification for ces 



Fred Bow en 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



37, $FFED SCRORG 



March 1, 1991 



Page 37 
preliminary 



;get current screen window size 



Preparation: 

Registers : 
Memory: 
Flags : 
Calls: 

Results: 

Registers: 

Memory: 
Flags: 



none 

system map 
none 
none 



-A = screen width 
.X = window width 
.Y - window height 

none 

none 



Example : 

JSR SFJED /SCRORG 

SCRORG returns active window;;s size (maximum row & column #) & origin 
entry: nothing required. 

^"""■^^ -c = maximum screen width (0=80, 1=40) default = n 

.X = maximum column number (# columns minus 1) default = 79 

.y - maximum line number (# lines minus 1 default = 24 



.a - window address (home position), low 
*z = window address, ^igh 



default = $0800 



System Specification for C65 Fred Bowen March 1, 1991 

C64DX KERNEL JUMP TABX£ Page 38 

DESCRIPTIONS preliminary 

38, $FFFO PLOT ; read/set cursor position 

Preparation: 

Registers; .X = cursor line 

.y = cursor column 

Memory: system map 

Flags: .C - — > set cursor position 
.C = 1 — > get cursor position 

Calls: none 

Results: 

Registers: .X = cursor line 

.Y = cursor column 

Memory: TBLX, PNTR updated 

Flags: .C = 1 — > error 

PLOT Reads or sets the cursor position within current window 

Entry: .c = 1 Returns the cursor position (.y=column, .K=line) 

relative to the current window origin (NOT screen origin) . 

.c = Sets the cursor position (.y=coluran, .x=line) relative 
to the current window origin (NOT screen origin) . 

Exit: > When reading position, .X-line, .Y^column, ,C=1 if wrapped line 

When setting new position, .X=line, .Y=column, and 

.c ss Normal exit. The cursor has been moved to the position 

contained in .x & .y relative to window origin 

(see SCRORG) . 

.c = 1 Error exit. The requested position was outside the 

current window (see SCRORG) . The cursor has not been 
moved. 



System Specification for CSS 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 199X 

Page 38A 
preliminary 



When called with the carry status set, PLOT returns 
the current cursor position relative to- the current 
window orxgin (NOT screen origin) . When called with 
the carray status clear, PLOT attempt to move the 
cursor to the indicated line and column relative to 
the current window origin (NOT screen origin) . PLOT 
will return a clear carry status if the cursor was 
moved, and a set carry status if the requested 
position was outside the current window (NO CHANGE 
has been made) . 



Editor variables that are useful: 



SCBOT 
SCTOP 
SCLF 
SCRT 



$E4 
$E5 
$E6 
$E7 



X3LX - $EC 
PNTR - $ED 

LINES - $EE 
COLUMNS $EF 



-> window bottom 
-> window top 
-> window left side 
-> window right side 

■> cursor line 
-> cursor column 

•> maximum screen height 
■> maximum screen width 



System Specification for CSS 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 39 
preliminary 



39. $FFF3 lOBASE 



;read base address of I/O block 



Preparation: 

Registers: 
Memory : 
Flags ; 
Calls : 



none 

system map 
none 
none 



Results : 

Registers : 

Memory: 
Flags: 



.X = Isb of I/O block 
.Y = msb of I/O block 

none 

none 



Example: 

JSR $FFF3 



;find the I/O block 



lOBASE is unused in the C64DX and is included for 
compatibility and completeness. It returns the 
address of the I/O block in .X and .Y. 



System Specification for C65 Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE «,« „n 

DESCRIPTIONS , . ?^^® ^° 

preliminary 

C. NEW C64DX KERNEL CALLS 



The followzng system calls comprise a set of extensions 

fn. ^h! r^^nv'^^'^'^v.-^^" ^^P ^^^^^- ^^«y ^^e specifically 
for the C64DX machine and and as such should not be 

^^H?i «^?K it permanent additions to the standard jump 
table. With the exception of C64MODE, they are all true 

S™? "?? ^?u "^^^ terminate via RTSs . As with all 
Kernel calls, the system configuration (BANK SFF) 
must be in context at the time of the call 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 41 

preliminary 



1. $FF4D SPIN SPOUT 



;setup fast serial ports for I/O 



Preparation: 






Registers : 


none 




Memory ; 


system map 




Flags: 


.C =^ --> 
.C =* 1 — > 


select SPINP 
select SPOUT 



Calls: 



none 



Results : 




Registers: 


.A used 


Memory: 


CIA-1, FSDIR register 


Flags: 


none 


Example : 




CLC 

JSR $FF4D 


/setup for fast seria 



The fast serial protocol utilizes CIA_1 
(6526 at $DCOO) and a special driver circuit 
controlled in part by the FSDIR register. SPINP and 
SPOUT are routines used by the system to set up the 
CIA and fast serial driver circuit for input or 
output. SPINP sets up CRA (CIA 1 register 14) and 
clears the FSDIR bit for input. 

SPOUT sets up CRA, ICR (CIA_1 register 13), timer A 
(CIA_1 registers 4 fi 5) , and sets the FSDIR bit for 
output. Note the state of the TODIN bit of CRA is - 
always preserved. These routines are required only 
applications driving the fast serial bus themselves 
from the lowest level . 



by 



System Specification for C65 

e64DX KEFKEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 42 
preliminary 



2. $FF50 CLOSE ALL 



/•close all files on a device 



Preparation: 






Registers: 


.A — > device # (FA: 


0-31) 


Memory: 


system map 




Flags: 


none 




Calls: 


none 




Results: 






Registers : 


.A used 
.X used 
.Y used 




Memory : 


none 




Flags: 


none 




Example: 






LDA #$08 
JSR $rF50 


; close ail files on de 


*vice 



The FAT is searched for the given FA. A proper CLOSE 
IS performed for all matches. If one of the CLOSEd 
channels is the current I/O channel then the default 
channel is restored. 

This call is utilized, for example, by the BASIC 
command ' DCLOSE ' . 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March I, 1991 



Page 43 

preliminary 



3. $FF53 C64MODE 



; reconfigure system as a c/64 



Preparation: 




Registers: 


none 


Memory ; 


system map 


Flags : 


none 


Calls: 


none 


Results: 




Registers : 


none 


Memory : 


none 


Flags : 


none 



Example: 

JMP $FF53 ; switch to C64 mode 



THERE IS NO RETURN FROM THIS ROUTINE. The system 
downloads code to RAM which reMAPs the system to 
put the C64 ROM in context, resets all VIC-III modes, 
and jumps to the C64 start routine. 

Return to C65 mode is by resetting the machine, although 
a program could do it very easily. A vector on the C64 
side is provided to restart C64DX mode. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 44 
preliminary 



4, $FF56 MonitorCall 



/enter Monitor mode 



Preparation: 




Registers: 


none 


Memory : 


system map 


Flags: 


none 


Calls: 


none 


Results: 




Registers: 


none 


Memory : 


none 


Flags: 


none 



Turns off BASIC receipt of IRQ, maps BASIC out, maps 
the Monitor in, and calls it. 

When the Monitor is exited, the system is restored, 
BASIC mapped in, and the system vector taken (usually 
points to BASIC warm Start entry) . 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX PCERNEL JUMP TABLE 
DESCRIPTIONS 



Page 45 

preliminary 



5. SFF59 BOOT SYS 



;boot an alternate OS from disk 



BOOT SYS 



> 



Preparation: 

Registers: 

Memory ; 

Flags: 

Calls: 
Results: 

Registers: 

Memory : 

^ Flags: 

Boot an alternate system. Reads the "home" sector of any 
diskette (physical track sector 1, 512 bytes) into memory 
at $00400, turns off BASIC, and JMPs to it. Nothing done if 
disk not present. JMP not made if first byte is not $4C. 

It forces the "system" memory map, not user environment. 

No support for C128-style BOOT sector. Not related to 
BASIC 10.0 BOOT command, which RUNs a BASIC program 
called "AUTOBOOT.C65*" if found. 



none 

system map 
none 
none 

undefined 
undefined 
undefined 



System Specification for C65 

C64DX KEE^NEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991- 



Page 4 6 
pre iirni nary 



6. $FF5C PHOENIX 



;???? CS4DX diagnostics ???? 



Preparation: 

Registers; 
Memory : 
Flags: 
Calls : 



none 

system map 
none 
none 



Results: 

Registers 

Memory; 

Flags: 



undefined 
undefined 
none 



Example: 

JSR $FF5C 



; PHOENIX 



Not same thing as C128 Phoenix routine. In the C65 development 
system, this routine is calli S after BASIC inits and performs 
some system diagnostics, displaying results on the screen. 



System Specification for C65 



Fred Bowen 



March 1, 1991 



C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Page 47 
preliminary 



7. $FF5F LKOPLA 

8. $FF62 LKUPSA 



; search tables for given la 
; search tables for given sa 



Preparation: 

Registers 



Memory: 
Flags : 
Calls : 



.A= LA (logical file number) 
if LKUPLA 

.Y= SA (secondary address) 
if LKUPSA 

system map 

none 

none 



Results: 

Registers 

Memory : 
Flags : 



.A = LA (only if found) 
.X = FA (only if found) 
.Y = SA (only if found) 

none , 

.0 = if found 

.C = 1 if not found 



Example : 

LDY #$60 
again INY 

CPY #$6F 
BCS too many 
JSR SFF"^2 
BCC again 



;find an available SA 



;too many files open 

; LKUPSA 

;get another if in use 



LKUPLA and LKUPSA are Kernel routines used primarily 
by BASIC DOS commands to work around a user's open 
disk channels. The Kernel requires unique logical 
device numbers (LAs) and the disk requires unique 
secondary addresses (SAs) , therefore BASIC must find 
alternative unused values whenever it needs to 
establish a disk channel. 



pecification for C65 


Fred Bowen ' March 1, 1991- 


C64DX KERNEL JUMP TABT,F. ' 
DESCRIPTIONS 


Page 48 

preliminary 


9. $i:'b'65 SWAPPER 


; switch between 40 & 80 column modes 


Preparation: 




Registers : none 


Memory : 


system map 


Flags: 


none 


Calls; 


none 



Results; 

Registers 

Memory: 
Flags: 



Example : 



LDA $D7 
BMI i. >80 
JSR $FF5F 



.A used 
.X used 
.Y used 

screen cleared 

none 



; check display mode 
/branch if 80 column 
/switch from 40 to 80 



MODE, location $D7, is toggled by SWAPPER to indicate 
the current display mode: $80= 80-column, $00- 
40-column. Because they are both VIC screens, changing 
them requires clearing the screens since they share the 
same memory location. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 4 9 
preliminary 



10. $FF68 PFKEY 



; program a function key 



Preparation; 

Registers 

Memory: 

Flags: 

Calls: 



.A = pointer to string adr 

(lo/hi/bank) 
.Y - string length 
.X = key number (1-16) 

system map 

none 

none 



Results : 

Registers 

Memory: 
Flags : 



.A used 
.X used 
.Y used 

PKYBUF, PKYDEF tables updated 

.C = if successful 
.C = 1 if no room 



Example : 



LDA #$FA ;pointer to string address 

LDY #6 , ; length 

LDX #15 ;key # ('HELP' key) 

JSR $FF68 ;install new key def'n 

BCS no room 



>OOOFA 00 13 00 



iptr to $1300 bank 



>01300 53 54 52 49 4E 47 :' string' 

PFKEY (alias KEYSET) is an Editor utility to * replace 
a function key string with a user's string. Keys 

1-14 are F1-F14, 15 is the HELP key, and 16 is the 
<shift>RUN string. The example above replaces the 
'help<cr>' string assigned at system initialization 
to the HELP key with the string 'string'. Both the 
key length table, PKYBUF ($1000-$100F) , and the 
definition area, PKYDEF (31010-$10FF) are compressed 
and updated. The maximum length of ail 16 strings is 
240 characters. No change is made if there is 
insufficient room for a new definition. 



System Specification for C65 Fred Bowen March 1, 199i 

C64DX KERNEL JTJMP TABLE p^„^ =n 

DESCRIPTIONS r.,-«.l^™?J^ 

preiuamary 

11. $FF6B SETBNK ;set bank for I/O operations 

; and filename 

Preparation: 

Registers: ,A - BA, memory bank (0-FF) 
.X = FNBANK, filename bank 

Memory : system map 
Flags : none 
Calls: SETNAM 

Results: 

Registers : none 

Memory; BA, FNBANK updated 

Flags: none 

Example; 

see OPEN 

SETBNK is a prerequisite for any memory I/O 

2?SS?E^°"^ ^^^ ^"^^^ ^® "2^^ along with SETLFS and 
SETNAM prior to OPENing files, etc. BA ($C6) sets the 
current 64KB memory, bank for LOAD /SAVE/VERIFY 
operations. FNBANK ($C7) indicates the bank in which 

IStomJ'-^^"^®^^®^'''-''^ /^ found, the Kernel routine 
SETBNK -IS often used along with 

SETNAM and SETLFS calls prior to OPENs. See the 

Kernel OPEN, LOAD, and SAVE calls for examples. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 51 
preliminary 



12. $FF6E JSRFAR 

13. $FF71 JMPFAR 



;gosxib in another bank 
;goto another bank 



Preparation: 

Registers 
Memory : 



none 

system map, also; 
$02 --> bank (0-FF) 
$03 --> PC_high 
$04 ~> PC_low 
$05 — > .3 (status) 
$06 ~> .A 
$07 --> .X 
$08 — > .Y 
$09 — > .Z 



Flags: 


none 


Calls: 


none 


Results: 




Registers: 


none 


Memory: 


as per call/ also: 




$05 — > .3 (status) 
$06 ~> .A 
$07 — > .X 
$08 — > .Y 
$09 — > .Z 



Flags: 



none 



The two routines, JSRFAR and JMPFAR., enable code 
executing in the system bank of memory to call (or 
JMP to) a routine in any other bank. In the case of 
JSRFAR, the called routine must restore the isystem map 
before executing a return. 

JSRFAR calls JMPFAR. Both are RAM routines, located 
at $39C and $3B1 respectively. 

The user should take necessary precautions when calling 
a non-system bank that interrupts (IRQs i NMIs) will be 
handled properly {or disabled beforehand) . 



System Specification for C65 

"C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bow en 



March 1, 1991 



Page 52 
preliminary 



14 . $FF74 LDA FAR 



;LDA (.X),Y from bank .2 



Preparation: 

Registers 



.A = none 

.X - pointer to base page pointer 

.Y - index 

.Z = bank (0-FF) 



Memory: 


setup indirect vector 


Flags : 


none 


Calls: 


none 


Results : 




Registers : 


.A = data 
,X used 


Memory : 


DMA_LIST updated 


Flags: 


status valid 



LDA_FAR enables applications to read data from any 
other bank. It builds a DMA_LIST to fetch one byte, 
executes the DMA, and reads the byte. It's a ROM routine 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bow en 



March 1, 1991 



Page 53 
preliminary 



15. $FF77 STA FAR 



;STA (.X),Y from bank .2 



Preparation: 

Registers: 

Memory: 
Flags : 
Calls: 



,A = data 

.X - pointer to base page pointer 

,Y = index 

-Z = bank (0-FF) 

setup indirect vector 

none 

none 



Results: 

Registers: 
Memory : 
Flags : 



.X used 

DMA__LIST 
status invalid 



STA_FAR enables applications to write data to any 
other bank. It builds a DMA_LIST to stash one byte, 
and executes the DMA. It's a ROM routine. 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 54 
preliminary 



16. $FF7A CMP FAR 



;CMP {.X),y from bank .2 



Preparation: 

Registers 



.A = data 

.X = pointer to a base page pointer 

.Y = index 

.Z =* bank (0-FF) 



Memory: 


setup indirect vecto 


Flags : 


none 


Calls: 


none 


Results: 




Registers: 


.X used 


Memory: 


none 


Flags: 


status valid 



CMP__FAR enables applications to compare data to any 
other bank. it builds calls LDA FAR and compares the 
given byte with the byte fetched. It's a ROM routine 



System Specification for C65 

C64DX KERNEL JUMP TABLE 
DESCRIPTIONS 



Fred Bowen 



March 1, 1991 



Page 55 
preliminary 



17. $FF7D PRIMM 



; print immediate utility 



Preparation: 






Registers: 


none 




Memory: 


none 




Flags: 


none 




Calls: 


none 




Results : 






Registers: 


none 




Memory: 


none 




Flags: 


none 




Example: 






JSR $FF7D 




■/display following text 


.BYTE 'message' 
.BYTE $00 


; terminator 


JMP continue 


; execution resumes here 



PRIMM is a Kernel utility used to print (to the 
default output device) a PETSCII string which 
immediately follows the call. The string must be no 
longer than 255 characters and be terminated by a 
null ($00) character. It cannot contain any embedded 
null _ characters . Because PRIMM uses the system stack 
to find the string and a return address, you MUST NOT 
JMP to PRIMM, There must be a valid address on the 
stack. * 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** F.BOWEN tlZ^/'^X 
3-4.6 BASIC 10.0 MATH PACFTACf: 

This document details the many user-callable routines 
available m the C64DX BASIC 10,0 math package. 

Floating Point Math Package Conventions 

In BASIC memory the number is PACKED and looks like this: 
\^ 2 3 4 5 " 

Isigned !B7=SGN I I | "7 

! 5H ' IM A N T I S S AJ LSB I 

I +$80 I MSB I I I I 

l^'^lAl^C^stn^f ^^r<.TrS ""V^f^^^^^ ?^ch that its msb is always 
i, BASIC Stores the SIGN of the mantissa here to. save a byte of 
storage. It must be normalized when put in the FACC (see CONUPKl 
In the FACC the NORMALIZED number looks like this: ^^NUPK) . 

T.™^ ^^^ ^^5 566 S67 $68 
— E™ FACHO^ FACMOH FACMO FACLO FACSGN 

Isigned |BIT 7=1 1 | | rsiGN'~7 
! f$S ' f" A N T I S S A LSB + = $00 

exponent is 10 38 (SFF) and the minimum is 10^-39 ($01) A zero 
value for the exponent means the number is zero SiAce "I 

!2friE^>l80/°:r -'h.'' i^'^L^" described as'^the nS^er^ol 
left (EXP>S80) or right {EXP<-$80 shifts to be performed on 
the normalized mantissa to create the binary representaU^on ot 

IkX^^'.J^^""^ ^? ^ ^^^°"^ floating accumulator called aIg 
which has the same layout. It is locatt^ri ai- <;*;a *.>,™t«l7 eV^ 

Throughout the math plckage the f!oat2Sg ^oint fomat ?s? ^ " 

* the mantissa is 24 bits long. 

* the binary point is to the left of the msb. 

* the mantissa is always positive, and its msb is always 1. 

* number = mantissa * 2^exponent, sign in FACSGN, 

* the sign of the exponent is the msb of the exponent. 

* the exponent is stored in excess $80 (i.e., it is a sifrn^^H 
8-bit number with $80 added to it!) signed 

* an exponent of zero means the number is zero, (note that the 
rest of the accumulator cannot be assumed to be zero.) 

* to keep the same number in the accumulator while shiftinc- 

right shifts — > increment exponent 
left shifts — > decrement exponent 

Arithmetic routine calling conventions: 



* For one argxjment functions : 

the argiament is in the FACC. 
the result is left in the FACC. 

* For two argument operations: 

the first argiiment is in MEMORY (packed) or ARG (unpacked) . 
the second argument is in the FACC . 
the result is left in the FACC. 

* Always call ROM routines with SYSTEM memory in context (BANK $FF) 

A note concerning precision. Since the mantissa is always 
normalized, the high order bit of the most significant byte is 
always one. This guarantees at least 40 bits (5 ' byte mantissa 
times 8* bits each) of precision, which is approximately 9 
significant digits plus a few bits for rounding. In fact, 
there is a 'rounding' byte, FACOV ($71), which should, for the 
greatest degree of precision/ be loaded whenever you load the 
FACC, The high order bit of FACOV is utilized in most of the 
math routines. While some of the 'movement' routines 'round' 
the loaded floating point number (i.e., FACOV = $00), others 
(such as CONUPK) do not- assuming the value of FACOV is the 
useful result of an operation in progress. In 99% of the cases 
you need not worry about it, as its significance is virtually 
nil. For the greatest degree of precision however, use it. 

A few examples of normalized (FACC) floating point numbers: 

VALUE EXP MANTISSA SIGN 



1E38 
4E10 
2E10 
lElO 
^10 

1 

.5 
.25 

.6 
lE-04 
lE-37 
lE-38 
3E-39 


-1 

-5 



FF 


96 


76 


99 


53 


00 


A4 


95 


02 


F9 


00 


00 


A3 


95 


02 


F9 


00 


00 


A4 


95 


02 


F9 


00 


00 


84 


AO 


00 


00 


00 


00 


81 ^ 


80 


.00 


00 


00 


00 


80 


80 


00 


00 


00 


00 


7F 


80 


00 


00 


00 


00 


80 


99 


99 


99 


9A 


00 


73 


Dl 


B7 


59 ., 


59 


00 


06 


88 


IC 


£A 


15 . 


-00 


02 


D9 


C7 


DC 


EE 


00 


01 


82 


AB 


IE 


2A 


00 


00 


XX 


XX 


XX 


XX 


00 


81 


80 


00 


00 


00 


,FF 


83 


AO 


0.0 


00 


00 


FF 



Now for a simple example of deriving the actual binary from the FACC 

5 = 83 AO 00 00 00 00 
I \ 
I \ 
($83-S80) ($A0) 
I I 

which means: 2^3 * .10100000, or shift mantissa LEFT 3, 

which gives: 101.00000 (binary) or 5.0 (hex) 



i 



BASIC 10.0 MATH PACKAGE ***PRELIMINARy*** 



F.BOWEN 



2/25/91 



: NAME; 

i FUNCTION: 

i 



RESULT: 

ERROR: 
EXAMPLE: 



AYINT 

CONVERT FLOATING POINT TO INTEGER 



PREPARATION: FACC contains floating point nojitiber (-32768<=n<=32767) 



FACMO (366) contains signed integer (msb) 
FACLO ($67) contains signed integer (Isb) 

?ILLEGAL QUANTITY ERROR if FACC too big. 



JSR AYINT 
LDA $66 
LDY $67 



; INT (FACC) 

/MSB 

;LSB 



NAME: 
FUNCTION: 

PREPARATION; 



RESULT : 
EXAMPLE: 



GIVAYF 

CONVERT INTEGER TO FLOATING POINT 

.A contains signed integer (msb) 
.Y contains signed integer (Isb) 

FACC contains floating point number 

LDA #>INTEGER 
LDY #<INTEGER 
JSR GIVAYF ; FLOAT (A, Y) 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT: 

EXAMPLE: 



FODT 

CONVERT FLOATING POINT TO ASCII STRING 

FACC contains floating point number 

FBUFFR ($100) contains ASCII string (null terminated) 
.A contains pointer to string (Isb) 
.Y contains pointer to string (msb) 

JSR POUT ; CONVERT FACC TO STRING AT $100 






* BASIC 


10.0 MATH PACKAGE ***PRELIMINARY*** F.BOWEN 


2/25/91 


NAME: 
FUNCTION: 


VAL 1 

CONVERT ASCII STRING TO FLOATING POINT 




PREPARATION: 


INDEXl ($24, $25) contains pointer to string 
.A contains length of string 




SPECIAL NOTES 


String *must* be in var_bank. Any 

invalid character terminates conversion when 

encountered (i.e., acts like a terminator). 




RESULT : 


FACC contains floating point number 




EXAMPLE: 


LDA #<POINTER 

LDY #>POINTER 

STA INDEXl ;SET POINTER TO STRING 

STY INDEX 1+1 ■ 

LDA #LENGTH ; SET STRING LENGTH 

JSR VAL_1 ;FACC ~ VAL (STRING) 




NAME: 
FUNCTION: 


f;RTADR 

CONVERT FLOATING POINT TO ADDRESS 




PREPARATION: 


FACC contains floating point number (0<=n<=S5535) 




RESULT: 


POKER ($16, $17) contains unsigned integer address 




ERROR: 


7ILLEGAL QUANTITY ERROR if FACC too big. 




EXAMPLE : 


JSR GETADR ; ADR (FACC) 
LDA $16 /LSB 
LDY $17 ;MSB 




=-=-=-=_=_=-=. 


.=-=-=-=-J=-=_=_ = _=_S=- = _=_=_ — _-._—« — _BS-=-=-=-5S-=-=S-Sa-=-=- = -= 


-=-=-=-= 


NAME: 
FUNCTION: ' 


t'LOATC 

CONVERT ADDRESS TO FLOATING POINT 




PREPARATION: 


FACHO ($64) contains address (msb) 
FACMOH ($65) contains address (Isb) 
.X contains exponent ($90 always) 
.0=1 if positive (always) 




RESULT: 


FACC contains floating point number 




ERROR: 


?0VERFL0W ERROR if FACC too big. 




EXAMPTiK: 


» 
LDA #<ADDRESS 
LDY #>ADDRESS 

STA FACMOH /SET ADDRESS 
STY FACHO 

LDX #$90 /EXPONENT 
SEC /POSITIVE 
JSR FLOATC /FLOAT ADDRESS 




i 







BASIC 10.0 MATH PACKAGE ***PRELIMINARy*** F.BOWEN 



2/25/91 



NAME: ■ 
FUNCTION: 

PREPAI^TION: 



SPECIAL NOTES 

RESULT: 

ERROR: 

EXAMPLE: 



FSDB 

FACC == MEMORY - FACC 

FACC contains floating point subtrahend 

*A - pointer (Isb) to packed floating point minuend 

.Y - pointer (msb) to packed floating point minuend 

The minuend *MUST* be in VARBANK in packed 
format. FSUB calls CONUPK to normalize it. 

FACC contains floating point difference 

?OVERFLOW ERROR if FACC tOO big. 

LDA #<POINTER 

LDY #>POINTER ;SET POINTER TO *PACKED* MINUEND 

JSR FSUB ; SUBTRACT MEMORY FROM FACC, DIFF IN FACC 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES 

RESULT: ' 

ERROR: 

EXAMPLE: 



FSDBT 

FACC = ARC - FACC 

FACC contains floating point subtrahend 
ARC contains floating point minuend 

This routine is similar to FSUB. The only difference 
t^ S^ ?Si^ to CONUPK- FSUBT assumes you have already 
loaded ARC with unpacked minuend.) 

FACC contains floating point difference 

?OVERFL0W ERROR if FACC too big. 

JSR FSUBT ; SUBTRACT ARC FROM FACC, DIFF IN FACC 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY^ 



F.BOWEN 



in^i^x 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES: 

RESULT : 

ERROR: 

EXAMPLE: 



FADD 

FACC = MEMORY + FACC 

FACC contains floating point addend 

.A - pointer (Isb) to packed floating point addend 

.Y = pointer (msb) to packed floating point addend 

The second addend *MUST* be in VARBANK in 

packed format. FADD calls CONUPK to normalize it. - 

FACC contains floating point sum 

70VERFL0W ERROR if result too big 



LDA #<POINTER 
LDY #>POINTER 
JSR FADD 



;SET POINTER TO *PACKED* ADDEND 
;ADD MEMORY TO FACC, SUM IN FACC 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES: 



x<ESULT : 

ERROR: 

EXAMPLE; 



FADDT 

FACC = ARG + FACC 

FACC contains floating point addend 
ARG contains' floating point addend 
ARISGN ($70) contains EOR (FACSGN, ARGSGN) 
.A contains FACEXP 

This routine is similar to FADD. The only 
difference is the call to CONUPK.) 

******* *********************»*#jr**********^***^ 

* You *MUST* put resultant sign in ARISGN. * 

* You *MUST* load FACEXP ($63) immediately. * 

* before call so that status flags are set! ' * 

*************«. ********************.***^***jt***** 

FACC contains floating point sum 

70VERFL0W ERROR if result too big 

LDA FACSGN 

EOR ARGSGN 

STA ARISGN ; SET RESULTANT SIGN 

LDA FACEXP ;SET STATUS FLAGS PER FACEXP 

JSR FADDT ;ADD ARG TO FACC* SUM IN FACC 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** 



F.BOWEN 



2fl^f'^\ 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES 

RESULT: 

ERROR: 

EXAMPLE: 



FITOLT 

FACC = MEMORY * FACC 

FACC contains floating point multiplier 

.A = pointer (Isb) to packed floating point- multiplicand 

.Y - pointer (msb) to packed floating point multiplicand 

The multiplicand *MUST* be in VARBANK in 

packed format. FMULT calls CONUPK to normalize it. 

FACC contains floating point product 

70VERFL0W ERROR if result too big 

LDA #<P0INTER" 

LDY #>P0INTER ;SET POINTER TO *PACKED* MULTIPLICAND 

JSR FMULT /MULTIPLY MEMORY BY FACC, PRODUCT IN FACC 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES 

RESULT : 

ERROR: 

EXAMPLE: 



FMOLTT 

FACC = ARG * FACC 

FACC contains floating point multiplier 
ARG contains floating point multiplicand 

This routine is similar to FMULT. The only difference 
IS the call to CONUPK- FMULTT assumes you have already 
loaded ARG with unpacked multiplicand. ) 

FACC contains floating point product 

?OVERFLOW ERROR if result too big 

JSR FMULTT' /MULTIPLY ARG BY FACC, PRODUCT IN FACC 






BASIC 


10,0 MATH PACKAGE ***PRELIMINARY*** F.BOWEN 2/25/91 


NAME: 
FUNCTION: 


FDIV 

FACC = MEMORY / FACC 


PREPARATION: 


FACC contains floating point divisor 

.A = pointer (Isb) to packed floating point dividend 

,Y = pointer (msb) to packed floating point dividend 


SPECIAL NOTES: 


The dividend *MUST* be in VARBANK in 

packed format. FDIV calls CONUPK to normalize it. 


RESULT: 


FACC contains floating point qpaotient 


ERROR: 


?DIVISION BY ZERO ERROR if FACC zero 


EXAMPLE; 


LDA #<POINTER 

LDY #>POINTER ;SET POINTER TO ^PACKED* DIVIDEND 

JSR FDIV ; DIVIDE MEMORY BY FACC, QUOTIENT IN FACC 


=-=-=-=-=-=-=- 


=- = -=5-=-=!-.as_=_-_--ss--_-_-_a_s=_=_-__„__=_=__„_„___^_____„_____,__,„_ 


NAME: 
FUNCTION: 


FDIVT 

FACC = ARG / FACC 


PREPARATION: 


FACC contains floating point divisor 
ARG contains floating point dividend 
ARISGN ($70) contains EORCFACSGN, ARGSGN) 
.A contains FACEXP 


SPECIAL NOTES: 
> 


This routine is similar to FDIV. The only difference 
is the call to CONUPK- FDIVT assumes you have already 
loaded ARG with unpacked dividend. ) 




*********************************************** 

* You *MUST* put resultant sign in ARISGN. * 

* You *MUST* load FACEXP ($63) immediately * 

* before call so that status flags are set! * 

*********************************************** 


RESULT: 


FACC contains floating point quotient 


ERROR: 


?DrVISION BY ZERO ERROR if FACC zero , 


EXAMPLE: 


LDA FACSGN 

EOR ARGSGN 

STA ARISGN ;SET RESULTANT SIGN 

LDA FACEXP ; SET STATUS FLAGS PER FACEXP 

JSR FDIVT /DIVIDE ARG BY FACC, QUOTIENT IN FACC 







BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** 



F.BOWEN 



2/25/91 



NAME: 
FUNCTION: 

PREP APAT ION: 

RESULT: 

ERROR: 

EXAMPLE: 



LOG 

FACC ^ LOG(FACC) natural logarithm (base e) 

FACC contains floating point ntamber 

FACC contains floating point logarithm 

?ILLEGAL QUANTITY ERROR if FACC negative or zero ■ 

JSR LOG ;FACC = LOG (FACC) 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT : 

EXAMPLE: 



INT 

FACC = INT (FACC) 

FACC contains floating point number 

FACC contains floating point greatest integer 

JSR INT ;FACC -^ INT (FACC) 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT : 

ERROR: 

EXAMPLE: 



SQR 

FACC ~ SQR (FACC) 

FACC contains floating point number 
FACC contains floating point square root 
?ILLEGAL QUANTITY ERROR if FACC negative 
JSR SQR ;FACC = SQR (FACC) 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT: 

EXAMPLE: 



KEGOP 

FACC * -FACC (invert sign of FACC) ' 

FACC contains floating point niimber 

FACC contains floating point number with sign inverted 

JSR NEGOP ;FACC = -FACC 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** 



F.BOWEN 



2/25/91 



NAME: 
FUNCTION: 

PREP AKAT ION: 



SPECIAL NOTES: 

RESULT: 
ERROR: 

EXAMPLE: 



FPHR 

FACC = ARG " MEMORY 

ARC contains floating point number 

.A = pointer (Isb) to packed floating point power 

.Y = pointer (msb) to packed floating point power 

The power *MUST* be in ROM or SYSTEM RAM in packed 
format as FPWR calls MOVFM to unpack it into FACC. 

FACC contains floating point result 

7ILLEGAL QUANTITY ERROR if ARG negative 
70VERFL0W ERROR if result too big 



LDA KPOINTER 
LDY #>POINTER 
JSR FPWR 



;SET POINTER TO *PAGKED* POWER 
/COMPUTE ARG "^ MEM, RESULT IN FACC 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES 



RESULT : 
ERROR: 

EXAMPLE: 



FPWRT 

FACC = ARG 



FACC 



ARG contains floating point nijmber 
FACC contains floating point power 
.A contains FACEXP 

This routine is similar to FPWR. The only difference 
is the call to MOVFM- FPWRT assumes you have already 
loaded FACC with unpacked power. 

* You *MUST* load FACEXP ($63) immediately * 

* before call so that status flags are set! * 

********** -k *i, *** **-k ittdf if iti, it ic*Kicitltl(tit ************ 

FACC contains floating point result 

7ILLEGAL QUANTITY ERROR if ARG negative 
70VERFL0W ERROR if result too big 



LDA FACEXP 
JSR FPWRT 



;SET STATUS FLAGS PER FACEXP 
/COMPUTE ARG '^ FACC, RESULT IN FACC 



NAME: 
FUNCTION: 

PREPARATION; 

RESULT: 

ERROR : 

EXAMPLE: 



EXP 

FACC ^ EXP (FACC) 



(compute e '' FACC) 



FACC contains floating point number 
FACC contains floating point result 
70VERFL0W ERROR if FACC too big 
JSR EXP ;FACC = EXP (FACC) 



BASIC 10.0 MATH PACKAGE ***PRELIMINAKY*** 



F.BOWEN 



2/25/91 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT: 

EXAMPLE: 



COS 

FACC = COS(FACC) 

FACC contains floating point number 

FACC contains floating point cosine (in radians) 

JSR COS ;FACC = COS (FACC) 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT: 
EXAMPLE: 



SIN 

FACC = SIN (FACC) 

FACC contains floating point number 

FACC contains floating point sine (in radians) 

JSR SIN ;FACC = SIN (FACC) 



NAME: 
FUNCTION: 

PREPARATION: 

RESULT: 

EXAMPLE: 



TAN 

FACC « TAN (FACC) 

FACC contains floating point number 

FACC contains floating point tangent (in radians) 

JSR TAN ;FACC = TAN (FACC) 



NAME: 
FUNCTION: 

PREPARATION 

RESULT; 

EXAMPLE: 



ATN 

FACC ** ATN (FACC) 

FACC contains floating point number 

FACC contains floating point arctangent (in radfans) 

JSR ATN ;FACC - ATN (FACC) 



a 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** 



F.BOWEK 



2/25/91 



NAME: 
FUNCTION: 

PREPARATION; 



RESULT: 



EXAMPLE: 



ROUND (round to 40 bits of precision) 

FACC = FACC + FACOV(msb) 

FACC contains floating point number 
FACOV (msb) contains ' extra' precision 

none if FACC zero or FACOV (msb) zero 

one extra bit ADDED to FACC Isb if FACOV (msb) is set 



JSR ROUND 



; ROUND FACC 



'lAME: 
FUNCTION: 

PREPARATION: 

RESULT : 

EXAMPLE: 



ABS 

FACC = ABS (FACC) 



(make FACSGN(msb) = $00) 



FACC contains (SIC3NED) floating point number 
FACC contains (POSITIVE) floating point 
JSR ABS ;FACC = ABS (FACC) 



NAME: 
FUNCTION: , 

PREPARATION; 

RESULT: 



EXAMPLE: 



SGN 

.A = SGN(FACC} 



(test SIGN of FACC) 



FACC contains floating point number 

.A — > $FF if FACC negative (FACC < 0) 

$O0-if FACC zero (FACC - 0) 

$01 if FACC positive (FACC > 0) 
(status flags reflect contents of .A, carry invalid) 



JSR SGN 



; SGN (FACC) 
; BEQ will trap =0 
; BNE will trap <>0 
.; BMI will trap <0 
; BPL will trap >=0 



etc. 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** 



F.BOWEN 



2/25/91 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES: 



RESULT: 



EXAMPLE: 



FCOMP 

-A = FCOMP (FACC, MEMORY) 



(compajre FACC with MEMORy) 



FACC contains floating point number 

.A = pointer (Isb) to packed floating point -number 

.Y =* pointer <msb) to packed floating point number 

The number *MUST* be in ROM, or RAM currently in context 
below ROM, in PACKED format. *** FACOV is significant! 

.A ~> $FF if FACC < MEMORY 

500 if FACC = MEMORY 

$01 if FACC > MEMORY 
(Status flags reflect contents of .A, carry invalid) 

LDA #<POINTER 

LDY #>POINTER ; SET POINTER TO *PACKED* NUMBER 

JSR FCOMP /COMPARE FACC WITH MEMORY 

; BEQ will trap FACC = MEM 
; BNE will trap FACC <> MEM 
; BMI will trap FACC < MEM 
; BPL will trap FACC >= MEM etc. 



NAME: 

FUNCTION: 

PREPARATION: 



SPECIAL NOTES: 

RESULT: 
EXAMPLE: 



RKDO 

FACC = random floating point number (0<n<l) 

•^ ^'^ IS? ^° generate a 'true' random number 

5°i; ^° generate next random number in sequence 
5FF to start a new sequence of random numbers 
based upon current contents of FACC. 

l^itll ^^ T^l^"^ "^^^ *^^^ ^^^^^"^ ^^"^ i" context. 
MUST* load .A immediately before call so that status 
flags reflect contents of .A 

FACC - floating point random number 

JSR RNDO 'START REPRODUCEABLE SEQUENCE BASED ON FACC 

LDA #$01 » 

JSR RNDO ; GENERATE (FIRST) RANDOM NUMBER IN SEQUENCE 



BASIC 10.0 MATH PACKAGE ***PRELIMINARY*** 



F.BOWEN 



2/25/91 



NAME: ■ 
FUNCTION: 

PREPARATION: 



CONUPK 

ARG = UNPACK (RAM_CONSTANT) 

,A = pointer (Isb) to packed floating point nimber 
.Y =s pointer (rasb) to packed floating point number 



SPECIAL NOTES: The number *MUST* be in VAPBANK or SYSTEM RAM in packed format. 
RESULT: 



EXAMPLE: 



ARG loaded with normalized floating point n-umber 
ARISGN {$6F) contains EOR{FACSGN,ARGSGN) 
.A contains FACEXP (status reflects contents of .A) 

LDA #<POINTER 

LDY #>POINTER ; SET POINTER TO *PACKED* NUMBER 

JSR CONUPK ;LOAD ARG 

; BEQ traps ARG = $00 



NAME: ■ 
FUNCTION: 

PREPARATION: 



SPECIAL MOTES: 



RESULT: 



EXAMPLE: 



ROMOPK 

ARG = UNPACK (ROM_CONSTANT) 

.A = pointer (Isb) to packed floating point number 
.Y = pointer (msb) to packed floating point number 

The number *MUST* be in ROM or SYSTEM RAM currently in context 
(otherwise identical to CONUPK) . 

ARG loaded with normalized floating point number 

ARISGN ($6F) contains EOR{FACSGN,ARGSGN) 

-A contains FACEXP (status reflects contents of .A) 



LDA #<POINTER 
LDY #>POINTER 
JSR ROMOPK 



;SET POINTER TO *PACECED* NUMBER 

;LOAD ARG 

; BEQ traps ARG = $00 



NAME: 
FUNCTION: 

PREPARATION: 



SPECIAL NOTES; 
RESULT: 

EXAMPLE: 



MOVFRM 

FACC = UNPACK (RAM_CONSTANT) 

.A = pointer (Isb) to packed floating point number 
.Y = pointer (msb) to packed floating point number 

The number *MUST* be in VARBANK or SYSTEM RAM in packed format 

FACC loaded with normalized floating point number 
FACOV ($71) cleared 

LDA #<POINTER 

LDY #>POINTER ;SET POINTER TO *PACKED* NUMBER 

JSR MOVFRM ;LOAD FACC 



BASIC 10.0 MATH PACKAGE ***PRELmiNARY*** 



F.BOWEN 



2/25/91 



NAME: 
FUNCTION: 

PREPARATION; 

RESULT: 

EXAMPLE; 



MOVFA 

FACC =* ARC 

ARG contains floating point number 

FACC contains same number as ARG 

FACOV ($71) cleared 

-A contains FACEXP (but status invalid!) 



JSR MOVFA 



;COPY ARG TO FACC 



\AME: 
UNCTION: 

PREPARATION; 

RESULT: 

EXAMPLE: 



MOVAF 

ARG « FACC 

FACC contains floating point number 



FACC 
ARG 
.A 



will be ROUNDed and FACOV cleared, 
contains same number as FACC 
contains FACEXP (but status invalid!) 



JSR MOVAF 



;COPY FACC TO ARG 



End of MATH ROUTINE documentation *** 



C64DX DOS ***PRELIMINARY*** F.BOWEN 2/25/91 

3.5 CSS DOS Documentation 



DIRECTORY HEADER DEFINITION 
BYTE DESCRIPTION 

TRACK number which points to the 1st dir. sector 

1 SECTOR number which points to the 1st dir. sector 

2 Disk format version number,, which is currently 'D' . 

512 byte sectors 20 per track 

20 Sectors per track 

40 Tracks per side 

2 sides (note they're inverted from normal MFM dsk) 

3 Must = 

4 Bytes 4 thru 21 contain the volume name (label) 
22 Bytes 22 and 23 contain the disk id (fake) 

24 Must contain an $A0 

25 DOS version number (CBDOS - 1, 1581 = 3 

26 Format version number (currently = 'D' (fake)) 

27 Bytes 27 thru 28 = SAG 

29 NOT USED AT THIS TIME 

30 NOT USED AT THIS TIME 
30 NOT USED AT THIS TIME 

32 NOT USED AT THIS TIME 

33 NOT USED AT THIS TIME 

34 Track number which points to this directory header 

35 Sector number which points to this directory header 

36 Bytes 3 6 thru 255 are not used at this time 

NOTE: If this is a subdirectory header then BYTES 32 and 33 contain the 
TRACK & <yCTOR number of the DIRECTORY SECTOR that points to this DIRECTORY 
HEADER. See the partition command for a better discription. If this is the 
ROOT header then they will contain a $00. 



C64DX DOS ***PRELIMINARy*** F.BOWEN 



2/25/91 



BAM DEFINITION 
BYTE DESCRIPTION 







Track link for next bam sector, if last then end of bams 

1 Sector link 

2 Format type this disk was formatted under 

3 Compliment version number of byte 2 above 
4-5 Disk ID used when this disk was formatted 

6 I/O byte used as follows; 

BIT 7 - When set Verify is performed after each disk write 
. BIT 6 - Perform CRC check (not used by CBDOS) 
BIT 1 - Huge relative files disabled 

7 Auto loader flag (not used by CBDOS) 
8-15 Not used at this time by any CBM DOS versions 

16 - 255 BAM image 



BAM IMAGE 



Number of free sectors on this track 

flag for sector 7, LSB flag for sector 
flag for sectorlS, LSB flag for sector 8 
flag for sector23, LSB flag for sectorl6 
flag for sector31, LSB flag for sector24 
flag for sectQr39, LSB flag for sector32 



- 


Num. 


1 - 


MSB 


2 - 


MSB 


3 - 


MSB 


4 - 


MSB 


5 - 


MSB 



CS4BX DOS ***5BELlWmAI0i:*** F .BO«ElI 2/25/91 

DIRECTORY SECTOR DEFINITION 
BYT BIT DESCRIPTION 

TRACK — Points to the next directory track. 

1 SECTOR — Points to the next directory sector* 

[IF TRACK = THEN THIS IS THE LAST DIRECTORY SECTOR] 

FILE ENTRY DESCRIPTION 
BYT BIT DESCRIPTION 

File status byte which is used as follows; 
7 Set indicates properly closed file 

6 File is locked (read only) 

5 Save with replace is CURRENTLY in effect, 
when file is closed this bit is deleted. 

4 NOT USED AT THIS TIME 

X Bits 3 thru are used to indicate the filetype 

= DEL, 1 = SEQ, 2 = PRG, 3 = USER, 4 = REL, 5 ^ CBM, 6 =not used 
7 = used by dos to represent DIRECT type of file access 

1 TRACK - link to the 1st sector of data for this file. 

2 SECTOR - link to the 1st sector of data for this file. 

3 Bytes 3 thru 18 contain the filename in ASCII, padded with $A0 

19 Side Sector TRACK link for relative files 

GEOS - Track number of GEOS file header 

20 Side Sector- SECTOR link for relative files 

GEOS - Sector number of GEOS file header 

21 Record size for relative files 

GEOS - File structure type = seq, 1 = VLIR 

22 GEOS - FILE TYPES: 

> 13= Swap file 12= System boot 11= Disk device 10= Input device 
09= Printer 08= Font 07= Appl. data 06= Applications 
05= Desk Ace. 04= System 03= Basic data 02= Assembly 
01= Basic 00= Not GEOS 

23 Not used by CBM DOS previous to CBDOS 

GEOS - DATE: Year last modified (offset from 1990) 
CBDOS- Bits 7-4 contain the upper 4 bif's from the file type byte 
(see byte above) for the UNNEW, UNSRATCH commands used by CBDOS 

24 Not used by CBM DOS previous to CBDOS 

GEOS - DATE: Month last modified ( 1 thru 12) 
CBDOS- Bit's 7 thru 4 contain the lower 4 

bit's from the file type byte (see byte 23 above) 

25 GEOS - DATE: Day last modified ( 1 thru 31) 

26 TRACK (from 1) for the save with replace file 

GEOS - DATE: Hour last modified (0 thru 23) 

27 SECTOR (from 2) for the save with replace 

GEOS - DATE: Minute last modified (0 thru 59) 

28 LSB of the # of sectors used by this file 

29 MSB of the # of sectors used by this file 

NOTE: Each sector in the directory contains 8 entries of 32 bytes each 



C64DX DOS 



***PRELIMINARY*** 



F.BOWEN 



m^i'ix 



SIDE SECTOR FORMAT DEFINITION 



BYTE 


1 
2 



3 

4-5 

6-7 

8-9 

10 - 11 

12 - 13 

14 - 15 

16 - 17 

18 - 19 

etc. 



DESCRIPTION 



Next Side Sector TRACK link {5FF if last) 
Next Side Sector SECTOR 
Side Sector number 

If this is a SUPER SIDE SECTOR then this contains an $FE 
(see the description of the SUPER SIDE SECTOR below) 
Record Size 

TRACK & SECTOR link of Side Sector number 
TRACK & SECTOR link of Side Sector number 1 
TRACK & SECTOR link of Side Sector number 2 
TRACK & SECTOR link of Side Sector number 3 
TRACK & SECTOR link of Side Sector number 4 
TRACK fi SECTOR link of Side Sector number 5 
TRACK & SECTOR link of the DATA BLOCK #0 
TRACK & SECTOR link of the DATA BLOCK #1 



NOTE: There are 91 groups to the largest file that this DOS can handle 



SUPER SIDE SECTOR FORMAT DEFINITION 
DESCRIPTION 



BYTE 










1 






2 






3 


_ 


4 


5 


_ 


6 


7 


- 


8 


9 


- 


10 


11 


- 


12 


13 


- 


14 


253 


- 


254 



Next Side Sector TRACK link ($FF if last) 
Next Side Sector SECTOR 

Contains an SFE to indicate this is a SUPER SIDED SECTOR 
TRACK £ SECTOR link of Side Sector number 
> TRACK & SECTOR link of Side Sector number 
TRACK s SECTOR link of Side Sector number 
TRACK s SECTOR link of Side Sector number 
TRACK s SECTOR link of Side Sector number 
TRACK & SECTOR link of Side Sector number 



TRACK & SECTOR link of Side Sector number 125 
NOTE: There are 91 groups to the largest file that this DOS can handle 



DATA SECTOR DEFINITION 
DESCRIPTION 



BYTE 



- 



TRACK and SECTOR link to the next data block. If track = 
then sector contains the number of bytes used in this sector 
(which will always be at least 2 on the last block for the 
T&S link bytes) . 



NOTE: Used by DEL, SEQ, PRG, REL (data blocks) and USR 



C64DX DOS 



***PRELIMINARy*** 



F.BOWEN 



2/25/91 



* Format a track 

* 10 sectors per track numbered 1-10, 512 byte sectors 



12 Sync marks 

3 Header ID marks w/missing clock 
1 Header ID 

4 Header bytes 



2 Header CRC bytes 
22 Data gap bytes 
12 Sync marks 

3 Data block ID marks w/missing clock 

1 Data block ID 

512 Data block fill bytes 

2 Data block CRC bytes 
Sector gap bytes 



24 



00 

Al 

FE 

Track 

Side 

Sector 

Sector 

XX, XX 

4E 
00 
Al 
FB 
00 

XX, XX 

4E 



s^ze 



* 

* Calculate the 2 byte CRC for each sector header of an entire track * 

* of 10 sectors. AXYZ are trashed. * 

* 

* 

* This routine is based on the Cyclical Redundancy Check on the * 

* polynomial : A''16+A''12+A^5+l . * 
* 

* HEADER contains TRACK, SIDE, SECTOR, 2 [sector size] * 

* DO WHILE ne = * 

* DO FOR each bit in the data byte (.a) [from Isb to msb] * 

IF (LSB of ere) EOR (LSB of, data) * 

* > THEN CRC = (CRC/2) EOR polynomial * 

ELSE CRC = (CRC/2) * 

* FI * 

* LOOP * 

* LOOP * 
* ^ ^ 

* „ 

* SIDE = CLogicalSector >= 20) AND 1 * 

* TRACK *= LogicalTrack -1 * 

* StartingSector = SIDE * 20 * * 

* SECTOR = (Logical Sector - StartingSector) /2 +1 * 

* HALF = (LogicalSector - StartingSector) AND 1 * 
* ,^ ^ _ — „«___^_ ^ * 



C64DX DOS ***PRELIMINARY*** F.BOWEN Z/2^/Sl 

CSS Partition and Subdirectory Syntax 910212 Fred Bowen 

This specification describes a proposed C6S partition/subdirectory parser. 

OPEN la,fa,sa, "[#] /path/: filename" 

OPEN la, fa, 15, "<cmd>#/path/: [cmd_string] " 

where: * ^, is an optional "drive" nxaraber, 0-9. 
/path/ is a partition or subdirectory name 
: delimits the path from the filename 

and: <cmd> is a DOS command {such as I,N,S,C, etc.) 

[cmd_string] xs an optional string required by some commands. 

^vL^trti?''^^^? illustrates a typical filename specification, the second 
example illustrates a command channel instruction, secona 



OPEN la,fa,sa, "0/SUBDIRl/SUBDIR2/:FILE, S,W" 



Action taken 



Why 




1. Select the "root" „ 

2. Find & enter two subdirectories /SUBDIR1/SUBDIR2/: 

<the trailing "/" is required 

3 ri-Pflt-P. z r^r^^r, -F-,' 1 ^ * • i. ■ to be Compatible with CMD?) 
J. i-reate & open file for writing FILE,S,W 

^^?i-i^fS°^"v,°''^"^^^^^ number", path, and ":" are all optional. If thev are 
Syntaxes Tre:^^^ '" °^^^^^ ^" "^"^^ ^""^"^ partition /some similar, aL^lSgal, 

OPEN la' fa' la' "O^Pifp^ «- create "FILE" in current part) 

OPENla,fa,sa, "//SUBDXR/ :FILE, S, W" iflT^ltV.rtU^oVl^lV 

OPEN la,fa,sa, "80/SaBDIR/:FILE" (op^-FILinr-lSlDIR-i:! ' 

writing) 

Some questionable syntaxes, and their affect, are: 

OPEN la,fa.sa, "OFILE,S,W" (this would create, file "OFTTTr"^ 

OPEN la,fa,sa, "/SUBDIR/FILE,S, W" createrfiirvSukDIR/FI^^ * 
OPEN ia,fa,sa, «@0:FrLE,S,W" (SpSf lue i|lli"'^n cuSnt* 

OPEN la,fa,sa, "/0:FILE, S,W« (rs^outrcfeatrfiiS^i-O :FILE" 
Some legal commands: """^^ ^^^^ ^= "°^ ^^^ ^^ *=^"1) 

OPEN ll'il'll' "^?;« {-itialize current partition) 

wren xa, ra,io, i// {initialize RooM 

SI™l^'f^'15, "lO/SUBDIR/:- enter "SraoYR" and initialize) 
S=^^ la, fa, 15, "NO/SUBDIR/:NAME,ID" (enter "SOBDIR" and "new" itf 
OPEN la, fa, 15, "SO/SUBDIR/:FILE" (delete "FILE" in "SUBDIR") 
OPEN la, fa, 15, "/0:SUBDIR" {issi partition 2ell^?"/" in 

this context is a command itself) 



C64DX DOS ***PRELIMINARY*** F.BOWEN 2/25/91 

Some proposed general rules, designed to be compatible with both the 1581 
subpartitioning syntax and CMD syntax: 

1 . The name of a subdirectory must always be separated from the 
filename by a colon (":"). 

2. Each subdirectory name must be delimited by a slash ("/••) . 

3. To select Root directory (partiton) , specify two slashes ("//")• 
This allows older applications specifying the drive number ("0:") 
to be run in a partition. 



CORREKT PARTITION ROUTINES 

-reate Partition: 

"/O :PAR_NAME, "+ (START-TRK) + (START-SECTOR) + (LO-BLKS) + (HI-BLKS) 

Select Partition: 

"/0:PAR_NAME" will select given filname as subdirectory 
"/O" will select root directory 

SELECT PARTITION 

This routine will allow the user to quickly select partition paths using 
the normal SA values other than 15. To use this new method the user opens 
the file using a normal SA and the filename MUST be structured as follows; 

"/<drive>:PATH_l/PATH__2/PATH_3 ETC 

If the dos does not find one of the filenames in the file path stream it 
will chpipk to see if the file exists in the current directory and if it 
does it will open the file in the normal method as it does now. 



C64DX DOS 



***PRELIMINARY 



*** 



F.BOWEN 



2/25/91 



*********-***1f**********l,*i,iii,*ic-ni,icific*i,**itirif1ciK*1c*1t**liic1ticicir*i(*i,i,i,itif1,^i,^,^^^^^^ 



FILE COMMANDS 



* The following set of command channel routines were added to allow the 
user a graceful way of manupilating files: 



F-L" Locate a file to prevent it from being scratched 
"F-U" Unlock a file and allow it to be scratched 
"F-R" Restore a file after it has been scratched 



Following each command above is the drive nuraber, followed by a colon 

* then followed by the filename(s). For example, to lock all the files 

* on drive you would send the following file command: 



OPENXX, xX, 15, "F-LO : * 



or 



OPENXX,XX,15,"F-LO:FNAME,FNAME1,FNAME2, .. . etc. 






Syntax 



BLOCK STATUS 
"B-S: CHANNEL NUMBER, DRIVE NUMBER, TRACK, SECTOR" 



Then check error channel for normal errors then get one byte * 
from the channel number. If it is a then the sector is free * 
1 indicates the sector is in use. * 

* 
This command was added to enable an easy method of finding out * 
If a given track or sector is currently marked as being used in * 
* a drive's BAM or not. 



CBDOS CHGUTIL 



COMMAND 



COMMENTS 



DRIVES USED ON 



* "UO>B"+chr$(n) b = set fast/slow serial bus 

* '•UO>D"+chr$(n) d = set dirsecinc 

* "UO>H"+chr$(n) h = set head selection 0, 1 

* "UO>M"+chr$ (n) m = set dos mode 

* '•UO>R''+chrS (n) r = set dos retries on errors 

= set secinc 
= set verify oN/oFF 

= set device number ^^ 

= set large rel files on/off CBDOS 
= perform memory read 1581 
= perform memory write 1581 



* "UO>S"+chr$(n) 

* "UO>V+-chr$ (n) 

* -UO>?"+chr$(n) 

* "UO>L"+chr$ (n) 

* "UO>MR"+ XX 

* "UO>MW"+ XX 

* 12345 

* A 



s 

V 
9 



1581 

CBDOS 

1571 

1571 

1571, 1581 

1571, 1581, CBDOS 

1581, CBDOS 

1571, 1581, CBDOS 



CMDSI2 points to end of string startina fll- 



C64DX DOS ***PRELIMINARY*** F.BOWEN 2/25/91 

FLOPPY DISK CQNTROT.T.ER ERRORS 

IP FDC DESCRIPTION 

(0) no error 

20 (2) can't find block header 

23 (5) checlcstim error in data 

25 (7) write-verify error 

26 (8) write w/ write protect on 

27 (9) ore error in header 

Information description 

1 files scratched 

2 selected partition 

3 files locked 

4 files unlocked 

5 files restored 

Parameter errors 

30 general syntax 

31 invalid coimnand 

32 long line 

33 invalid filname 

34 no filenames given 

Relative file errors 



50 record not present 

51 overflow in record 

52 file too large 

53 big relative files disabled 

Open routine errors 

60 file open for write 

61 file not open 

62 file not found 

63 file exists 

64 file type mismatch 

Sector management errors 

65 no block 

66 illegal track or sector 

67 illegal system t or s I 



C64DX DOS ***PRELIMINARY*** F.BOWEN 2/25/91 



General channel /block errors 

02 channel selected 

70 no channels available 

71 bam corrupted error 

72 disk full 

73 cbdos vl.O 

74 drive not ready 

75 format error 

76 controller error 

77 sleeted partition illegal 

78 directory full 

79 file corrupted 



C64DX RS-232 



***PRELIMINARY 



*** 



F.BOWSN 



2/25/91 



3.6 C64DX RS-232 DRIVER 

0OA7 rs232_status 
00A8 rs232_flags 



00A9 rs232_jam 
OOAA rs232_xon char 
00 A3 rs232 xofl char 



OOBO 


rs232 xmit empty 




GOBI 


rs232 rcvr buffer 


lo 


0OB2 


rs232 rcvr buffer 


hi 


00B3 


rs232 xinit buffer 


lo 


00B4 


rs232 xmit buffer 


hi 


0OB5 


rs232 high water 




00B6 


rs232_low_water 




00C4 


rs232 rcvr head 




00C6 


rs232 rcvr tail 




O0C8 


rs232 xmit head 




OOCA 


rs232 xmit tail 





UART status byte 

open flag, xon/xoff status 

b 7 : channe 1 op en ' (reset) 

b6: flow control (l=x-line) 

b5: duplex (l=half) 

bl: XOFF received 

bO: XOFF sent 

system character to xmit 

XON character (null=disabled) 

XOFF character (null'=disabled) 

xmit buffer empty flag (0=empty) 
lowest page of input buffer, 
highest page of input buffer 
lowest page of output buffer 
highest page of output buffer 
point at which receiver XOFFs 
point at which receiver XONs 

pointer to end of buffer 
pointer to start of buffer 
pointer to end of buffer 
pointer to start of buffer 



RS-232 interrupt-driven handler 

How it works: when an RS232 channel is OPENed, buffers are flushed, all 
flags and states are reset, and the receiver IRQ is enabled. When a byte 
is put into the xmit buffer by BSOUT, the xmit IRQ is enabled. The xmit 
IRQ 'is disabled whenever the xmit buffer is found to be empty or an XOFF 
is receive XL (it is enabled whenever an XON is received) . CLOSE will hang 
until the xmit buffer is empty, and BSOUT will hang when the xmit buffer 
is full. IRQs must be allowed by the user at all times (and especially 
during BSOUT calls) for proper operation (The RS232 channel will work even 
if IRQs are disabled by the user, but thoughput will be reduced to the 
frame rate (normal system raster IRQ) and the system can hang forever should 
•he xmit buffer become full and BSOUT is called with a byte to xmit) . A 
sucessful CLOSE will disable all RS232 interrupts and re-init everything. 

Note that DOS calls disable both IRQ and NMI interrupts while the DOS code 
is in context- The remote should be XOFFed to avoid loss of dajca. 

Refer to the UART specification for register description & baud rate tables. 



Open an RS-232 channel 
This is different from the usual C64/C128 command string. 



Command string bytes : 



12 3 4 5 6 

baudi wordl parity I stop (unused) 1 duplex i xline 



System Specification for C65 Fred Bowen March 1, 1991 

4.0 C64DX DEVEIOPMENT SUPPORT 



Please photocopy the attached 'C64DX PROBLEM REPORT' and 
use it to report any problems. 

If you have any requests or recommendations, please send 
a good description of it and explain why you want it. 



C64DX FBOBLEH REPORT 



Date 



Please complete this form as completely as possible and mail or express it to: 



Commodore Business Machines, Inc. 

1200 Wilson Drive 

West Chester, PA 19380 



Telephone: 215-431-9427 
Fax: 215-431-9156 
Email : fredScbmvax. commodore . com 



Company Name 



Company Address 



Attention: Fred Bowen, Engineering 



Your Name 



Your system 
Serial No._ 
4510 rev 



Peripherals : 



Your problem 



Your Phone 



PCB rev 



4567 rev 



Software ver 
FOIKDOS) 



ROM Cksum 
F018 (DMA) 



C64 mode 
> 

C640X mode 

Hardware 

Software 

Mechanical 

Documentation 

Compatibility 



Explain problem here and show how to cause it. Attach sample program, 



It happens: 



all the time 



In your opinion, how bad is the problem? 
Check here if you need to be contacted 



Please leave this space blank 



Number 



Received 



Contacted 



frequently 



occasionally 



Must fix, no workaround 
I can work around it 
Minor problem 



Completed 



C64DX System Specification UPDATE 



F.BOWEN 5/1/91 



The Monitor parser now allows PETSCII input/conversion: 



'A 

>1800 'text 



prints ASCO value of character 
puts text into memory 



IRQ runs during graphics (Kernel finds its own base page) . IRQ 
still does not run during DOS activity (not sure if they ever will) 

The following Kernel Jump Table Entries have moved (and are still 
subject to further changes) : 



FF05 


nirq 


; IRQ handler 


FF07 


monitor brk 


;BRK handler (Monitor) 


FF09 


nnmi 


;NMI handler 


FFOB 


nop en 


; open 


FFOD 


nclose 


; close 


FFOF 


nchkin 


; chkin 


FFll 


nckout 


; ckout 


FF13 


nclrch 


;clrch 


FF15 


nbasin 


; basin 


FF17 


nbsout 


; bsout 


FF19 


nstop 


; stop key scan 


FFIB 


ngetin 


; get in 


FFID 


nclall 


;clall ■ 


FFIF 


monitor_parser 


/monitor command parser 


FF21 


nload 


; load 


FF23 


nsave 


; save 


FF25 


talk 




FF27 


listen 




FF29 


talksa 




FF2B 


second 




FF2D 


acptr 




FF2F 


ciout 




FF31 


untalk 




FF33 


unlisten 




FF35 


DOS talk 




FF37 


DOS listen 


i 


FF39 


DOS talksa 


■ 


FF3B 


DOS_second 




FF3D 


DOS_acptr 




FF3F 


DOS ciout 




FF41 


DOS_untalk 




FF43 


DOS_unlisten 




FF45 


Get_DOS 




FF47 


Leave DOS 




FF49 


ColdStartDOS 


<« new 


FF4B 


WarmStartDOS 


«< new 



C54DX System Specification UPDATE 



F.BOWEN 5/1/91 



2.1.2 German/Austrian Keyboard Layout 



RUN 
STOP 



ESC 



ALT 



ASC 
DIIJ 



NO 
SCRL 



Fl 
F2 



F3 
F4 



F5 

F6 



F7 
F8 



F9 

no 



Fll 
F12 



F13 
F14 



HELP 



> 
*- < 


[ 
1 


n 

2 


* § 
3 


$ 
4 


% 

5 


6 


' / 
7 


( 
8 


) 
9 





+ B 


_ / 


1 
t [ 


CLR 
HOME 


INST 
DEL 


TAB 


Q 




E 


R 


T 


Z 
Y 


U 


I 





P 





* 
* + 




RSTR 


CTRL 1 SHFT 
LOCK 


A 


S 


D 


F. 


G 


H 


J 


K 


L 


[ 


] A 


1 

_ a 
— V 


RETURN 


C= 


SHIFT 


Y 

2 


X 


C 


V 




B 


N 


M 

■ 


< ; 

1 


> : 


9 

/ - 


SHIFT CRSR 
t 

1 — 














SPACE 




CRSR CRSR CRSR 
♦- 4 -♦ 



Notes : 



1/ 

2/ 
3/ 



4/ 



The operation of national keyboards is identical to C128 implementation. 
The ASCII/DIN key replaces the CAPS LOCK key, and can be toggled anytime 
to switch keyboard modes and automatically change the display. 

The national' keyboard contains key legends for both national and ASCII 
modes. The national legends appear on the right top/bottom of the keys. 

The German keyboard has three (3) "deadkeys." They are 'accent d'aigue, 
accent grave, and accent circonflex. Pressing the "deadkey followed by 
a valid vowel or accent character will 'build' the desired character: 



accent d' ai gue : 
accent grave: 
accent circonflex: 



e 

a, e, u 

a, e, i, 5, Q 



National character ROM graphic characters differ from the C64 and ASCII 
(English) graphic character sets. ^ 



C64DX System Specification UPDATE F.BOWEN 5/1/91 

PAINT X, y [/Color] 

Working, but not completely to spec. Uses draw pen 
color and fills emptyness to any border. 

RND(O) Improved for better "randomness" . Uses unused POT 

of second SID chip. PCB must allow lines to float. 

SET DISK # (without [TO #] parameter) allows user to clear DSS - 
message and specify which drive next DSS comes from. 

SET VERIFY <ONiOFF> 

The new DOS65 defaults to verify-after-write OFF. 
This command works with 1581 drive, too. 



Negative Coordinates are now allowed for all graphics commands. Some 
commands require their arguments to be "onscreen", such as PAINT- 
BASIC errors now force text mode, and TYPE, LIST, DISK, KEYLOAD, 
LOAD IFF now catch all DOS errors. Autoboot filename= AUTOBOOT.C64DX.* 

Opening an RS-232 channel, command string allows setting new features: 

1 baud (0-16, where 16«MIDI rate) 

2 word len 

3 parity 

4 stop bits (not used) 

5 duplex 

6 xline 

7 xon char (O=incoming flow control disabled) 

8 xoff char (O=outgoing flow control disabled) 
9,10 input buffer pointer <page lo, hi) 

11,12 output buffer pointer (page lo, hi) 

13 high water mark (point at which xoff is xmitted) 

14 low water mark (point at which xon is xmitted) 

For debug purposes, the border color will change if art RS232 buffer 
overflow occurs. To differentiate between a GET# of a null and a 
'no data' null, test bit 3 of STatus (same as C64) . 

Support for latest DOS controller chip, FOllD, includes error LED 
blink (border color still changes too, for now) . Changes to improve 
FASTLOAD speed and improve SAVE speed. Will work with FOllC chip, 
but error LED does not blink. Requires latest 'ELMER' PAL for disk 
LED to work correctly for either controller chip. External drive LED 
will not work correctly until new PCB & F016 chip are designed. New 
DOS functions include COPY DO TO Dl, ability to change sector skews 
for files (UO>S#) -and directory (UO>D#) , and directory compress 
(i.e., empty trash) via "£" command. Physical interleave is now 7. 

The DOS COPY/CONCAT bugs have been fixed, and COPY now allows forms 
such as COPY DO,"*. SRC" TO 01,"*" and COPY DO,"*=SEQ" TO Dl,"*". 
Directory/partition paths not yet implemented, but will be. 



C64DX System Specification UPDATE 



F.BOWEN 5/1/91 



The following changes/updates/fixes have been made to the C64DX ROM 
code since the March 1, 1991 C64DX System Specification was printed. 
Please make note of them. Current ROM as of this update is 910501. 



CHAR 



Now works to spec and supports the following imbedded 
control characters {although some are buggy; others 
are planned) : 



F 


6 


flip 




I 


9 


invert 







15 


overwrite 




R 


18 


reverse field 


on 




146 


reverse field 


off 





21 


underline 




y 


25 


tilt 




'Z 


26 


mirror 





When specifying a character set from ROM, note that 
national versions of the C64DX will have the national 
character set at $39000 and the C64 character set at 
$3DOO0. In US/English systems, the default C64DX-mode 
character set will be at 539000. 



CLR ERRS 



Clears BASIC error stuff, useful after a TRAP 



CURSOR [<ON|OFF>,] [column] I, row] [, style] 

where: column, row = x,y logical screen position 
style = flashing (0) or solid {!) 
ON, OFF = to turn the cursor on or off 

LINE xO, yO [, [xl] [,yll]... . . 

where; (xl,yl) = (xO,yO) if not specified, drawing a dot. 

Additional coordinates (x2,y2}, etc. draw a line from 
the previous point. 

LOADIFF "file" [,U#,D#] ^ ^^ 

Loads an IFF picture from disk. Requires a suitable 
graphic screen to be already opened (tHis may change) . 
The file must contain std IFF data in PRG file type. 
IFF pics can be ported directly from Amiga (eg., using 
XMODEM). Returns 'File Data Error' if it finds data 
it does not like. 



MOD (number , modu lus ) 

New function. 



MOUSE ON [,[portl [, [sprite] [, [hotspot] [,X/yposition) ]]) 

MOUSE OFF , « .^-u /^ ^u^ 

where: port '= (1...3) for joyport 1^ 2, or either (both) 
sprite = (0..,7) sprite pointer 
hotspot = X, y offset in sprite, default 0,0 
position = normal, relative, or angluar coordinates 
Defaults to sprite 0, port 2, last hotspot (0,0), and 
position. Kernel doesn't let hotspot leave the screen